This is a migrated thread and some comments may be shown as answers.

RadMaskedTextInput not firing GotTouchCaptureEvent

1 Answer 48 Views
MaskedInput (Numeric, DateTime, Text, Currency)
This is a migrated thread and some comments may be shown as answers.
George
Top achievements
Rank 1
George asked on 05 May 2016, 01:58 PM

I have an app that runs on a touchscreen and I am trying to capture the GotTouchCaptureEvent so that I can display the onscreen keyboard when the textbox is touched. It worked fine for a TextBox, but I am converting to RadMaskedTextInput controls to take advantage of the input masking and input validation. The event is fired from the TextBoxes (it works as desired if I change RadTouchTextBox to derive from TextBox), but not from the RadMaskedTextInput controls. The GotFocus and the LostKeyboardFocusEvent both work fine.

Here is the code:

ViewModel:

    public class RadTouchTextBox : RadMaskedTextInput
    {
        /// <summary>
        /// TextBox class with event handlers
        /// </summary>
        public RadTouchTextBox()
        {
                this.GotFocus += TextBox_GotFocus;
                this.GotTouchCapture += TextBox_GotTouchCapture;
                this.LostKeyboardFocus += TextBox_LostKeyboardFocusEvent;
        }

         private static void TextBox_GotFocus(object sender, RoutedEventArgs e)
        {
            (sender as TextBox)?.SelectAll();
        }

        private static void TextBox_GotTouchCapture(object sender, RoutedEventArgs e)
        {
            try
            {
                Process.Start(@"c:\Program Files\Common Files\microsoft shared\ink\tabtip.exe");
            }
            catch
            {
                // if the tabtip display fails for any reason, do nothing.
            }
        }

        private static void TextBox_LostKeyboardFocusEvent(object sender, RoutedEventArgs e)
        {
            Process[] processlist = Process.GetProcesses();

            foreach (Process process in processlist)
            {
                if (process.ProcessName == "TabTip")
                {
                    try
                    {
                        process.Kill();
                    }
                    catch
                    {
                        // if killing the process fails, ignore
                    }
                    break;
                }
            }
        }

 

        public string ServerPath
        {
            get { return GetProperty<string>(); }
            set { SetProperty(value); }
        }

 

xaml:

 

<DockPanel>

.

.

.

         <RadTouchTextBox Width="300" Margin="5" FontSize="24"
                 Value="{Binding ServerPath, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay, ValidatesOnExceptions=True}"
</DockPanel>

 

Any help is appreciated.

 

George

 

1 Answer, 1 is accepted

Sort by
0
George
Top achievements
Rank 1
answered on 05 May 2016, 02:46 PM
Got it! Turns out that reading the documentation actually provides some useful information. I needed to capture the TouchDown event, not the GotTouchCaptureEvent.
Tags
MaskedInput (Numeric, DateTime, Text, Currency)
Asked by
George
Top achievements
Rank 1
Answers by
George
Top achievements
Rank 1
Share this question
or