LineEdit.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  1. // Copyright (c) 2008-2022 the Urho3D project
  2. // License: MIT
  3. #include "../Precompiled.h"
  4. #include "../Core/Context.h"
  5. #include "../Input/Input.h"
  6. #include "../UI/LineEdit.h"
  7. #include "../UI/Text.h"
  8. #include "../UI/UI.h"
  9. #include "../UI/UIEvents.h"
  10. #include "../DebugNew.h"
  11. #include <SDL/SDL.h>
  12. namespace Urho3D
  13. {
  14. StringHash VAR_DRAGDROPCONTENT("DragDropContent");
  15. extern const char* UI_CATEGORY;
  16. LineEdit::LineEdit(Context* context) :
  17. BorderImage(context),
  18. lastFont_(nullptr),
  19. lastFontSize_(0),
  20. cursorPosition_(0),
  21. dragBeginCursor_(NINDEX),
  22. cursorBlinkRate_(1.0f),
  23. cursorBlinkTimer_(0.0f),
  24. maxLength_(0),
  25. echoCharacter_(0),
  26. cursorMovable_(true),
  27. textSelectable_(true),
  28. textCopyable_(true)
  29. {
  30. clipChildren_ = true;
  31. SetEnabled(true);
  32. focusMode_ = FM_FOCUSABLE_DEFOCUSABLE;
  33. text_ = CreateChild<Text>("LE_Text");
  34. text_->SetInternal(true);
  35. cursor_ = CreateChild<BorderImage>("LE_Cursor");
  36. cursor_->SetInternal(true);
  37. cursor_->SetPriority(1); // Show over text
  38. SubscribeToEvent(this, E_FOCUSED, URHO3D_HANDLER(LineEdit, HandleFocused));
  39. SubscribeToEvent(this, E_DEFOCUSED, URHO3D_HANDLER(LineEdit, HandleDefocused));
  40. SubscribeToEvent(this, E_LAYOUTUPDATED, URHO3D_HANDLER(LineEdit, HandleLayoutUpdated));
  41. }
  42. LineEdit::~LineEdit() = default;
  43. void LineEdit::RegisterObject(Context* context)
  44. {
  45. context->RegisterFactory<LineEdit>(UI_CATEGORY);
  46. URHO3D_COPY_BASE_ATTRIBUTES(BorderImage);
  47. URHO3D_UPDATE_ATTRIBUTE_DEFAULT_VALUE("Clip Children", true);
  48. URHO3D_UPDATE_ATTRIBUTE_DEFAULT_VALUE("Is Enabled", true);
  49. URHO3D_UPDATE_ATTRIBUTE_DEFAULT_VALUE("Focus Mode", FM_FOCUSABLE_DEFOCUSABLE);
  50. URHO3D_ACCESSOR_ATTRIBUTE("Max Length", GetMaxLength, SetMaxLength, 0, AM_FILE);
  51. URHO3D_ACCESSOR_ATTRIBUTE("Is Cursor Movable", IsCursorMovable, SetCursorMovable, true, AM_FILE);
  52. URHO3D_ACCESSOR_ATTRIBUTE("Is Text Selectable", IsTextSelectable, SetTextSelectable, true, AM_FILE);
  53. URHO3D_ACCESSOR_ATTRIBUTE("Is Text Copyable", IsTextCopyable, SetTextCopyable, true, AM_FILE);
  54. URHO3D_ACCESSOR_ATTRIBUTE("Cursor Blink Rate", GetCursorBlinkRate, SetCursorBlinkRate, 1.0f, AM_FILE);
  55. URHO3D_ATTRIBUTE("Echo Character", echoCharacter_, 0, AM_FILE);
  56. }
  57. void LineEdit::ApplyAttributes()
  58. {
  59. BorderImage::ApplyAttributes();
  60. // Set the text's position to match clipping and indent width, so that text left edge is not left partially hidden
  61. text_->SetPosition(GetIndentWidth() + clipBorder_.left_, clipBorder_.top_);
  62. // Sync the text line
  63. line_ = text_->GetText();
  64. }
  65. void LineEdit::Update(float timeStep)
  66. {
  67. if (cursorBlinkRate_ > 0.0f)
  68. cursorBlinkTimer_ = fmodf(cursorBlinkTimer_ + cursorBlinkRate_ * timeStep, 1.0f);
  69. // Update cursor position if font has changed
  70. if (text_->GetFont() != lastFont_ || text_->GetFontSize() != lastFontSize_)
  71. {
  72. lastFont_ = text_->GetFont();
  73. lastFontSize_ = text_->GetFontSize();
  74. UpdateCursor();
  75. }
  76. bool cursorVisible = HasFocus() ? cursorBlinkTimer_ < 0.5f : false;
  77. cursor_->SetVisible(cursorVisible);
  78. }
  79. void LineEdit::OnClickBegin(const IntVector2& position, const IntVector2& screenPosition, MouseButton button, MouseButtonFlags buttons, QualifierFlags qualifiers,
  80. Cursor* cursor)
  81. {
  82. if (button == MOUSEB_LEFT && cursorMovable_)
  83. {
  84. i32 pos = GetCharIndex(position);
  85. if (pos != NINDEX)
  86. {
  87. SetCursorPosition(pos);
  88. text_->ClearSelection();
  89. }
  90. }
  91. }
  92. void LineEdit::OnDoubleClick(const IntVector2& position, const IntVector2& screenPosition, MouseButton button, MouseButtonFlags buttons, QualifierFlags qualifiers,
  93. Cursor* cursor)
  94. {
  95. if (button == MOUSEB_LEFT)
  96. text_->SetSelection(0);
  97. }
  98. void LineEdit::OnDragBegin(const IntVector2& position, const IntVector2& screenPosition, MouseButtonFlags buttons, QualifierFlags qualifiers,
  99. Cursor* cursor)
  100. {
  101. UIElement::OnDragBegin(position, screenPosition, buttons, qualifiers, cursor);
  102. dragBeginCursor_ = GetCharIndex(position);
  103. }
  104. void LineEdit::OnDragMove(const IntVector2& position, const IntVector2& screenPosition, const IntVector2& deltaPos, MouseButtonFlags buttons,
  105. QualifierFlags qualifiers, Cursor* cursor)
  106. {
  107. if (cursorMovable_ && textSelectable_)
  108. {
  109. i32 start = dragBeginCursor_;
  110. i32 current = GetCharIndex(position);
  111. if (start != NINDEX && current != NINDEX)
  112. {
  113. if (start < current)
  114. text_->SetSelection(start, current - start);
  115. else
  116. text_->SetSelection(current, start - current);
  117. SetCursorPosition(current);
  118. }
  119. }
  120. }
  121. bool LineEdit::OnDragDropTest(UIElement* source)
  122. {
  123. if (source && editable_)
  124. {
  125. if (source->GetVars().Contains(VAR_DRAGDROPCONTENT))
  126. return true;
  127. StringHash sourceType = source->GetType();
  128. return sourceType == LineEdit::GetTypeStatic() || sourceType == Text::GetTypeStatic();
  129. }
  130. return false;
  131. }
  132. bool LineEdit::OnDragDropFinish(UIElement* source)
  133. {
  134. if (source && editable_)
  135. {
  136. // If the UI element in question has a drag-and-drop content string defined, use it instead of element text
  137. if (source->GetVars().Contains(VAR_DRAGDROPCONTENT))
  138. {
  139. SetText(source->GetVar(VAR_DRAGDROPCONTENT).GetString());
  140. return true;
  141. }
  142. StringHash sourceType = source->GetType();
  143. if (sourceType == LineEdit::GetTypeStatic())
  144. {
  145. auto* sourceLineEdit = static_cast<LineEdit*>(source);
  146. SetText(sourceLineEdit->GetText());
  147. return true;
  148. }
  149. else if (sourceType == Text::GetTypeStatic())
  150. {
  151. auto* sourceText = static_cast<Text*>(source);
  152. SetText(sourceText->GetText());
  153. return true;
  154. }
  155. }
  156. return false;
  157. }
  158. void LineEdit::OnKey(Key key, MouseButtonFlags buttons, QualifierFlags qualifiers)
  159. {
  160. bool changed = false;
  161. bool cursorMoved = false;
  162. switch (key)
  163. {
  164. case KEY_X:
  165. case KEY_C:
  166. if (textCopyable_ && qualifiers & QUAL_CTRL)
  167. {
  168. i32 start = text_->GetSelectionStart();
  169. i32 length = text_->GetSelectionLength();
  170. if (text_->GetSelectionLength())
  171. GetSubsystem<UI>()->SetClipboardText(line_.SubstringUTF8(start, length));
  172. if (key == KEY_X && editable_)
  173. {
  174. if (start + length < line_.LengthUTF8())
  175. line_ = line_.SubstringUTF8(0, start) + line_.SubstringUTF8(start + length);
  176. else
  177. line_ = line_.SubstringUTF8(0, start);
  178. text_->ClearSelection();
  179. cursorPosition_ = start;
  180. changed = true;
  181. }
  182. }
  183. break;
  184. case KEY_V:
  185. if (editable_ && textCopyable_ && qualifiers & QUAL_CTRL)
  186. {
  187. const String& clipBoard = GetSubsystem<UI>()->GetClipboardText();
  188. if (!clipBoard.Empty())
  189. {
  190. // Remove selected text first
  191. if (text_->GetSelectionLength() > 0)
  192. {
  193. i32 start = text_->GetSelectionStart();
  194. i32 length = text_->GetSelectionLength();
  195. if (start + length < line_.LengthUTF8())
  196. line_ = line_.SubstringUTF8(0, start) + line_.SubstringUTF8(start + length);
  197. else
  198. line_ = line_.SubstringUTF8(0, start);
  199. text_->ClearSelection();
  200. cursorPosition_ = start;
  201. }
  202. if (cursorPosition_ < line_.LengthUTF8())
  203. line_ = line_.SubstringUTF8(0, cursorPosition_) + clipBoard + line_.SubstringUTF8(cursorPosition_);
  204. else
  205. line_ += clipBoard;
  206. cursorPosition_ += clipBoard.LengthUTF8();
  207. changed = true;
  208. }
  209. }
  210. break;
  211. case KEY_HOME:
  212. qualifiers |= QUAL_CTRL;
  213. [[fallthrough]];
  214. case KEY_LEFT:
  215. if (cursorMovable_ && cursorPosition_ > 0)
  216. {
  217. if (textSelectable_ && qualifiers & QUAL_SHIFT && !text_->GetSelectionLength())
  218. dragBeginCursor_ = cursorPosition_;
  219. if (qualifiers & QUAL_CTRL)
  220. cursorPosition_ = 0;
  221. else if (text_->GetSelectionLength() && !(qualifiers & QUAL_SHIFT))
  222. cursorPosition_ = text_->GetSelectionStart();
  223. else
  224. --cursorPosition_;
  225. cursorMoved = true;
  226. if (textSelectable_ && qualifiers & QUAL_SHIFT)
  227. {
  228. i32 start = dragBeginCursor_;
  229. i32 current = cursorPosition_;
  230. if (start < current)
  231. text_->SetSelection(start, current - start);
  232. else
  233. text_->SetSelection(current, start - current);
  234. }
  235. }
  236. if (!(qualifiers & QUAL_SHIFT))
  237. text_->ClearSelection();
  238. break;
  239. case KEY_END:
  240. qualifiers |= QUAL_CTRL;
  241. [[fallthrough]];
  242. case KEY_RIGHT:
  243. if (cursorMovable_ && cursorPosition_ < line_.LengthUTF8())
  244. {
  245. if (textSelectable_ && qualifiers & QUAL_SHIFT && !text_->GetSelectionLength())
  246. dragBeginCursor_ = cursorPosition_;
  247. if (qualifiers & QUAL_CTRL)
  248. cursorPosition_ = line_.LengthUTF8();
  249. else if (text_->GetSelectionLength() && !(qualifiers & QUAL_SHIFT))
  250. cursorPosition_ = text_->GetSelectionStart() + text_->GetSelectionLength();
  251. else
  252. ++cursorPosition_;
  253. cursorMoved = true;
  254. if (textSelectable_ && qualifiers & QUAL_SHIFT)
  255. {
  256. i32 start = dragBeginCursor_;
  257. i32 current = cursorPosition_;
  258. if (start < current)
  259. text_->SetSelection(start, current - start);
  260. else
  261. text_->SetSelection(current, start - current);
  262. }
  263. }
  264. if (!(qualifiers & QUAL_SHIFT))
  265. text_->ClearSelection();
  266. break;
  267. case KEY_DELETE:
  268. if (editable_)
  269. {
  270. if (!text_->GetSelectionLength())
  271. {
  272. if (cursorPosition_ < line_.LengthUTF8())
  273. {
  274. line_ = line_.SubstringUTF8(0, cursorPosition_) + line_.SubstringUTF8(cursorPosition_ + 1);
  275. changed = true;
  276. }
  277. }
  278. else
  279. {
  280. // If a selection exists, erase it
  281. i32 start = text_->GetSelectionStart();
  282. i32 length = text_->GetSelectionLength();
  283. if (start + length < line_.LengthUTF8())
  284. line_ = line_.SubstringUTF8(0, start) + line_.SubstringUTF8(start + length);
  285. else
  286. line_ = line_.SubstringUTF8(0, start);
  287. text_->ClearSelection();
  288. cursorPosition_ = start;
  289. changed = true;
  290. }
  291. }
  292. break;
  293. case KEY_UP:
  294. case KEY_DOWN:
  295. case KEY_PAGEUP:
  296. case KEY_PAGEDOWN:
  297. {
  298. using namespace UnhandledKey;
  299. VariantMap& eventData = GetEventDataMap();
  300. eventData[P_ELEMENT] = this;
  301. eventData[P_KEY] = key;
  302. eventData[P_BUTTONS] = (unsigned)buttons;
  303. eventData[P_QUALIFIERS] = (unsigned)qualifiers;
  304. SendEvent(E_UNHANDLEDKEY, eventData);
  305. }
  306. return;
  307. case KEY_BACKSPACE:
  308. if (editable_)
  309. {
  310. if (!text_->GetSelectionLength())
  311. {
  312. if (line_.LengthUTF8() && cursorPosition_)
  313. {
  314. if (cursorPosition_ < line_.LengthUTF8())
  315. line_ = line_.SubstringUTF8(0, cursorPosition_ - 1) + line_.SubstringUTF8(cursorPosition_);
  316. else
  317. line_ = line_.SubstringUTF8(0, cursorPosition_ - 1);
  318. --cursorPosition_;
  319. changed = true;
  320. }
  321. }
  322. else
  323. {
  324. // If a selection exists, erase it
  325. i32 start = text_->GetSelectionStart();
  326. i32 length = text_->GetSelectionLength();
  327. if (start + length < line_.LengthUTF8())
  328. line_ = line_.SubstringUTF8(0, start) + line_.SubstringUTF8(start + length);
  329. else
  330. line_ = line_.SubstringUTF8(0, start);
  331. text_->ClearSelection();
  332. cursorPosition_ = start;
  333. changed = true;
  334. }
  335. }
  336. break;
  337. case KEY_RETURN:
  338. case KEY_RETURN2:
  339. case KEY_KP_ENTER:
  340. {
  341. // If using the on-screen keyboard, defocus this element to hide it now
  342. if (GetSubsystem<UI>()->GetUseScreenKeyboard() && HasFocus())
  343. SetFocus(false);
  344. using namespace TextFinished;
  345. VariantMap& eventData = GetEventDataMap();
  346. eventData[P_ELEMENT] = this;
  347. eventData[P_TEXT] = line_;
  348. SendEvent(E_TEXTFINISHED, eventData);
  349. return;
  350. }
  351. default: break;
  352. }
  353. if (changed)
  354. {
  355. UpdateText();
  356. UpdateCursor();
  357. }
  358. else if (cursorMoved)
  359. UpdateCursor();
  360. }
  361. void LineEdit::OnTextInput(const String& text)
  362. {
  363. if (!editable_)
  364. return;
  365. bool changed = false;
  366. // Send text entry as an event to allow changing it
  367. using namespace TextEntry;
  368. VariantMap& eventData = GetEventDataMap();
  369. eventData[P_ELEMENT] = this;
  370. eventData[P_TEXT] = text;
  371. SendEvent(E_TEXTENTRY, eventData);
  372. const String newText = eventData[P_TEXT].GetString().SubstringUTF8(0);
  373. if (!newText.Empty() && (!maxLength_ || line_.LengthUTF8() + newText.LengthUTF8() <= maxLength_))
  374. {
  375. if (!text_->GetSelectionLength())
  376. {
  377. if (cursorPosition_ == line_.LengthUTF8())
  378. line_ += newText;
  379. else
  380. line_ = line_.SubstringUTF8(0, cursorPosition_) + newText + line_.SubstringUTF8(cursorPosition_);
  381. cursorPosition_ += newText.LengthUTF8();
  382. }
  383. else
  384. {
  385. // If a selection exists, erase it first
  386. i32 start = text_->GetSelectionStart();
  387. i32 length = text_->GetSelectionLength();
  388. if (start + length < line_.LengthUTF8())
  389. line_ = line_.SubstringUTF8(0, start) + newText + line_.SubstringUTF8(start + length);
  390. else
  391. line_ = line_.SubstringUTF8(0, start) + newText;
  392. cursorPosition_ = start + newText.LengthUTF8();
  393. }
  394. changed = true;
  395. }
  396. if (changed)
  397. {
  398. text_->ClearSelection();
  399. UpdateText();
  400. UpdateCursor();
  401. }
  402. }
  403. void LineEdit::SetText(const String& text)
  404. {
  405. if (text != line_)
  406. {
  407. line_ = text;
  408. cursorPosition_ = line_.LengthUTF8();
  409. UpdateText();
  410. UpdateCursor();
  411. }
  412. }
  413. void LineEdit::SetCursorPosition(i32 position)
  414. {
  415. assert(position >= 0);
  416. if (position > line_.LengthUTF8() || !cursorMovable_)
  417. position = line_.LengthUTF8();
  418. if (position != cursorPosition_)
  419. {
  420. cursorPosition_ = position;
  421. UpdateCursor();
  422. }
  423. }
  424. void LineEdit::SetCursorBlinkRate(float rate)
  425. {
  426. cursorBlinkRate_ = Max(rate, 0.0f);
  427. if (cursorBlinkRate_ == 0.0f)
  428. cursorBlinkTimer_ = 0.0f; // Cursor does not blink, i.e. always visible
  429. }
  430. void LineEdit::SetMaxLength(i32 length)
  431. {
  432. assert(length >= 0);
  433. maxLength_ = length;
  434. }
  435. void LineEdit::SetEchoCharacter(c32 c)
  436. {
  437. echoCharacter_ = c;
  438. UpdateText();
  439. }
  440. void LineEdit::SetCursorMovable(bool enable)
  441. {
  442. cursorMovable_ = enable;
  443. }
  444. void LineEdit::SetTextSelectable(bool enable)
  445. {
  446. textSelectable_ = enable;
  447. }
  448. void LineEdit::SetTextCopyable(bool enable)
  449. {
  450. textCopyable_ = enable;
  451. }
  452. bool LineEdit::FilterImplicitAttributes(XMLElement& dest) const
  453. {
  454. if (!BorderImage::FilterImplicitAttributes(dest))
  455. return false;
  456. XMLElement childElem = dest.GetChild("element");
  457. if (!childElem)
  458. return false;
  459. if (!RemoveChildXML(childElem, "Name", "LE_Text"))
  460. return false;
  461. if (!RemoveChildXML(childElem, "Position"))
  462. return false;
  463. childElem = childElem.GetNext("element");
  464. if (!childElem)
  465. return false;
  466. if (!RemoveChildXML(childElem, "Name", "LE_Cursor"))
  467. return false;
  468. if (!RemoveChildXML(childElem, "Priority", "1"))
  469. return false;
  470. if (!RemoveChildXML(childElem, "Position"))
  471. return false;
  472. if (!RemoveChildXML(childElem, "Is Visible"))
  473. return false;
  474. return true;
  475. }
  476. void LineEdit::UpdateText()
  477. {
  478. i32 utf8Length = line_.LengthUTF8();
  479. // If maxLength_ nonzero, truncate line to enforce length
  480. if (maxLength_ && utf8Length > maxLength_)
  481. {
  482. line_ = line_.SubstringUTF8(0, maxLength_);
  483. utf8Length = maxLength_;
  484. }
  485. if (!echoCharacter_)
  486. {
  487. text_->SetText(line_);
  488. }
  489. else
  490. {
  491. String echoText;
  492. for (i32 i = 0; i < utf8Length; ++i)
  493. echoText.AppendUTF8(echoCharacter_);
  494. text_->SetText(echoText);
  495. }
  496. if (cursorPosition_ > utf8Length)
  497. {
  498. cursorPosition_ = utf8Length;
  499. UpdateCursor();
  500. }
  501. using namespace TextChanged;
  502. VariantMap& eventData = GetEventDataMap();
  503. eventData[P_ELEMENT] = this;
  504. eventData[P_TEXT] = line_;
  505. SendEvent(E_TEXTCHANGED, eventData);
  506. }
  507. void LineEdit::UpdateCursor()
  508. {
  509. i32 x = text_->GetCharPosition(cursorPosition_).x_;
  510. text_->SetPosition(GetIndentWidth() + clipBorder_.left_, clipBorder_.top_);
  511. cursor_->SetPosition(text_->GetPosition() + IntVector2(x, 0));
  512. cursor_->SetSize(cursor_->GetWidth(), text_->GetRowHeight());
  513. IntVector2 screenPosition = ElementToScreen(cursor_->GetPosition());
  514. SDL_Rect rect = {screenPosition.x_, screenPosition.y_, cursor_->GetSize().x_, cursor_->GetSize().y_};
  515. SDL_SetTextInputRect(&rect);
  516. // Scroll if necessary
  517. i32 sx = -GetChildOffset().x_;
  518. i32 left = clipBorder_.left_;
  519. i32 right = GetWidth() - clipBorder_.left_ - clipBorder_.right_ - cursor_->GetWidth();
  520. if (x - sx > right)
  521. sx = x - right;
  522. if (x - sx < left)
  523. sx = x - left;
  524. if (sx < 0)
  525. sx = 0;
  526. SetChildOffset(IntVector2(-sx, 0));
  527. // Restart blinking
  528. cursorBlinkTimer_ = 0.0f;
  529. }
  530. i32 LineEdit::GetCharIndex(const IntVector2& position)
  531. {
  532. IntVector2 screenPosition = ElementToScreen(position);
  533. IntVector2 textPosition = text_->ScreenToElement(screenPosition);
  534. if (textPosition.x_ < 0)
  535. return 0;
  536. for (i32 i = text_->GetNumChars(); i >= 0; --i)
  537. {
  538. if (textPosition.x_ >= text_->GetCharPosition(i).x_)
  539. return i;
  540. }
  541. return NINDEX;
  542. }
  543. void LineEdit::HandleFocused(StringHash /*eventType*/, VariantMap& eventData)
  544. {
  545. if (eventData[Focused::P_BYKEY].GetBool())
  546. {
  547. cursorPosition_ = line_.LengthUTF8();
  548. text_->SetSelection(0);
  549. }
  550. UpdateCursor();
  551. if (GetSubsystem<UI>()->GetUseScreenKeyboard())
  552. GetSubsystem<Input>()->SetScreenKeyboardVisible(true);
  553. }
  554. void LineEdit::HandleDefocused(StringHash /*eventType*/, VariantMap& /*eventData*/)
  555. {
  556. text_->ClearSelection();
  557. if (GetSubsystem<UI>()->GetUseScreenKeyboard())
  558. GetSubsystem<Input>()->SetScreenKeyboardVisible(false);
  559. }
  560. void LineEdit::HandleLayoutUpdated(StringHash /*eventType*/, VariantMap& /*eventData*/)
  561. {
  562. UpdateCursor();
  563. }
  564. }