Reputation: 203
Hello I want to add some customized gesture (i made) functions on inkcanvas
But I don't know how to do that when the inputdevicetype is touch like this
inkcanvas.InkPresenter.InputDeviceTypes = Windows.UI.Core.CoreInputDeviceTypes.Touch;
when the input device type is touch, then i can't use any gestures
Because the all inputs are recognized the drawn
when using inkcanvas with touch input, can't i use gesture functions?
private void ink1_PointerPressed(object sender, PointerRoutedEventArgs e)
{
PointerDeviceType pointerDevType = e.Pointer.PointerDeviceType;
pointers = new Dictionary<uint, Windows.UI.Xaml.Input.Pointer>();
e.Handled = true;
PointerPoint ptrPt = e.GetCurrentPoint(ink1);
m_pt.Add(ptrPt);
if (!pointers.ContainsKey(ptrPt.PointerId))
{
// Add contact to dictionary.
pointers[ptrPt.PointerId] = e.Pointer;
}
switch (ptrPt.PointerDevice.PointerDeviceType)
{
case Windows.Devices.Input.PointerDeviceType.Mouse:
ink1.InkPresenter.InputDeviceTypes = Windows.UI.Core.CoreInputDeviceTypes.Mouse;
ink1.RightTapped += ink1_RightTapped;
break;
case PointerDeviceType.Touch:
if (m_pt.Count == 2)
{
ink1.InkPresenter.InputDeviceTypes = Windows.UI.Core.CoreInputDeviceTypes.None;
ink1.RightTapped += ink1_RightTapped;
}
else if (m_pt.Count == 1 || m_pt.Count > 2)
{
ink1.InkPresenter.InputDeviceTypes = Windows.UI.Core.CoreInputDeviceTypes.Touch;
ink1.RightTapped += ink1_RightTapped;
}
break;
}
}
When i press my ink1(inkcanvas) with 2 fingers, then i want to use my gesture functions (draw letter L or tap the inkcanvas 3 times) what i made
such as uwp's doubletapped, righttapped etc.
Upvotes: 0
Views: 295
Reputation: 10627
I saw you use the PointerPress
event handle for InkCanvas
.
The configuration of the InkPresenter
determines the pointer event handling behavior of the InkCanvas
. You must set InkPresenter.InputDeviceTypes
to CoreInputDeviceTypes.None
for the InkCanvas
to process pointer events, otherwise they are passed to the InkPresenter
object.
To handle pointer events with the InkPresenter
object, you must set RightDragAction
to LeaveUnprocessed
to pass the input through as UnprocessedInput
for custom processing by your app.
inkCanvas.InkPresenter.InputProcessingConfiguration.RightDragAction = InkInputRightDragAction.LeaveUnprocessed;
Details please reference the remark section of InkCanvas
.
Upvotes: 1