eDosStationFull/eDosStation/TouchEnabledTextBox.cs
2026-08-18 12:15:26 +02:00

58 lines
1.6 KiB
C#

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
namespace eDosStation
{
public class TouchEnabledTextBox : TextBox
{
//inside the class definition
private Process _touchKeyboardProcess = null;
public TouchEnabledTextBox()
{
this.GotFocus += TouchEnabledTextBox_GotFocus;
//this.GotTouchCapture += TouchEnabledTextBox_GotTouchCapture;
this.LostFocus += TouchEnabledTextBox_LostFocus;
}
private void TouchEnabledTextBox_GotFocus(object sender, RoutedEventArgs e)
{
string touchKeyboardPath = @"C:\Program Files\Common Files\Microsoft Shared\Ink\TabTip.exe";
_touchKeyboardProcess = Process.Start(touchKeyboardPath);
}
private void TouchEnabledTextBox_GotTouchCapture(object sender, System.Windows.Input.TouchEventArgs e)
{
string touchKeyboardPath = @"C:\Program Files\Common Files\Microsoft Shared\Ink\TabTip.exe";
_touchKeyboardProcess= Process.Start(touchKeyboardPath);
}
//add this method as a member method of the class
private void TouchEnabledTextBox_LostFocus(object sender, RoutedEventArgs eventArgs)
{
if (_touchKeyboardProcess != null)
{
_touchKeyboardProcess.Kill();
//nullify the instance pointing to the now-invalid process
_touchKeyboardProcess = null;
}
}
}
}