aboutsummaryrefslogtreecommitdiff
path: root/CruUI/ui/controls/text_box.cpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2018-09-24 00:22:04 +0800
committercrupest <crupest@outlook.com>2018-09-24 00:22:04 +0800
commit9049f7674e0808cc3676543e0a95330a1657d10e (patch)
tree1bfbdcc2a25316d6e85cc9b4527a1ec15841b502 /CruUI/ui/controls/text_box.cpp
parent977c766e2337fea238804b8d8b97659361391ed0 (diff)
downloadcru-9049f7674e0808cc3676543e0a95330a1657d10e.tar.gz
cru-9049f7674e0808cc3676543e0a95330a1657d10e.tar.bz2
cru-9049f7674e0808cc3676543e0a95330a1657d10e.zip
Add left and right support.
Diffstat (limited to 'CruUI/ui/controls/text_box.cpp')
-rw-r--r--CruUI/ui/controls/text_box.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/CruUI/ui/controls/text_box.cpp b/CruUI/ui/controls/text_box.cpp
index 53417d40..a8d78398 100644
--- a/CruUI/ui/controls/text_box.cpp
+++ b/CruUI/ui/controls/text_box.cpp
@@ -125,6 +125,22 @@ namespace cru::ui::controls
is_caret_show_ = false;
}
+ void TextBox::OnKeyDownCore(events::KeyEventArgs& args)
+ {
+ Control::OnKeyDownCore(args);
+ if (args.GetVirtualCode() == VK_LEFT && position_ > 0)
+ {
+ position_--;
+ Repaint();
+ }
+
+ if (args.GetVirtualCode() == VK_RIGHT && position_ < GetText().size())
+ {
+ position_++;
+ Repaint();
+ }
+ }
+
void TextBox::OnCharCore(events::CharEventArgs& args)
{
Control::OnCharCore(args);