File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change 22
33#include < scratchcpp/textbubble.h>
44#include < scratchcpp/value.h>
5+ #include < scratchcpp/iengine.h>
56
67#include " textbubble_p.h"
78
@@ -70,6 +71,13 @@ void TextBubble::setText(const std::string &text)
7071 impl->text = converted.substr (0 , limit);
7172
7273 impl->textChanged (impl->text );
74+
75+ if (!impl->text .empty ()) {
76+ IEngine *eng = engine ();
77+
78+ if (eng)
79+ eng->moveDrawableToFront (this );
80+ }
7381}
7482
7583/* ! Emits when the text changes. */
Original file line number Diff line number Diff line change 11#include < scratchcpp/textbubble.h>
2+ #include < enginemock.h>
23
34#include " ../common.h"
45
@@ -36,8 +37,12 @@ TEST(TextBubbleTest, BubbleText)
3637 bubble.setText (" hello" );
3738 ASSERT_EQ (bubble.text (), " hello" );
3839
40+ EngineMock engine;
41+ bubble.setEngine (&engine);
42+ EXPECT_CALL (engine, moveDrawableToFront (&bubble));
3943 bubble.setText (" world" );
4044 ASSERT_EQ (bubble.text (), " world" );
45+ bubble.setEngine (nullptr );
4146
4247 // longstr.length = 384, should be limited to 330 in bubble text
4348 std::string longstr =
You can’t perform that action at this time.
0 commit comments