diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-02-19 19:10:55 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-02-19 19:10:55 +0200 |
| commit | 10e1892e2ff3620d5111c3b8e5c9eea5baa08a1a (patch) | |
| tree | c5a2f02332896ed2b5972abde7d6abfb50565500 /Software/Visual_Studio/Tango.Touch/Controls/TouchTextBox.cs | |
| parent | e17d15cb372dbae9a11c09d76f8ca14265f40334 (diff) | |
| download | Tango-10e1892e2ff3620d5111c3b8e5c9eea5baa08a1a.tar.gz Tango-10e1892e2ff3620d5111c3b8e5c9eea5baa08a1a.zip | |
Implemented some improvements for PPC.
Diffstat (limited to 'Software/Visual_Studio/Tango.Touch/Controls/TouchTextBox.cs')
| -rw-r--r-- | Software/Visual_Studio/Tango.Touch/Controls/TouchTextBox.cs | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchTextBox.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchTextBox.cs index 76e99ff88..6f8297a5e 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchTextBox.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchTextBox.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -20,6 +21,7 @@ namespace Tango.Touch.Controls public class TouchTextBox : TouchInput { private TextBox _text_box; + private DateTime _lost_focus_time; public String Text { @@ -82,10 +84,17 @@ namespace Tango.Touch.Controls _text_box = GetTemplateChild("PART_TextBox") as TextBox; _text_box.GotFocus += _text_box_GotFocus; + _text_box.LostFocus += _text_box_LostFocus; + this.RegisterForPreviewMouseOrTouchUp(OnMouseOrTouchUp); } + private void _text_box_LostFocus(object sender, RoutedEventArgs e) + { + _lost_focus_time = DateTime.Now; + } + private void OnMouseOrTouchUp(object sender, MouseOrTouchEventArgs e) { if (TapCommand != null) @@ -96,15 +105,18 @@ namespace Tango.Touch.Controls private async void _text_box_GotFocus(object sender, RoutedEventArgs e) { - await Task.Delay(50); - - if (FocusSelectionMode == FocusSelectionMode.SelectAll) - { - _text_box.SelectAll(); - } - else if (FocusSelectionMode == FocusSelectionMode.ScrollToEnd) + if (DateTime.Now > _lost_focus_time.AddMilliseconds(200)) { - _text_box.CaretIndex = _text_box.Text.Length; + await Task.Delay(50); + + if (FocusSelectionMode == FocusSelectionMode.SelectAll) + { + _text_box.SelectAll(); + } + else if (FocusSelectionMode == FocusSelectionMode.ScrollToEnd) + { + _text_box.CaretIndex = _text_box.Text.Length; + } } } |
