1

I am not able to make PointerPressed, PointerReleased (any pointer event) work.

I have written this line of code to support touch

inkCanvas.InkPresenter.InputDeviceTypes = CoreInputDeviceTypes.Mouse | CoreInputDeviceTypes.Touch;

from the solutions that I found online, I have tried this

inkCanvas.PointerReleased += inkCanvas_PointerReleased;

and this

inkCanvas.AddHandler(PointerReleasedEvent, new PointerEventHandler(inkCanvas_PointerReleased), true);

and simply through XAML as well:

     <InkCanvas x:Name="inkCanvas" 
PointerPressed="inkCanvas_PointerPressed" 
PointerMoved="inkCanvas_PointerMoved" PointerReleased="inkCanvas_PointerReleased" 
Tapped="inkCanvas_Tapped">

I am testing the app in my device (not on emulator). what is it that I am missing?

saira
  • 23
  • 5
  • Missing syntax `Windows.UI.Core.CoreInputDeviceTypes.***` for the [properties](https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.input.inking.inkpresenter.inputdevicetypes.aspx). – Chris W. Jul 19 '16 at 20:09
  • 1
    @ChrisW. `Windows.UI.Core` is included via `using` statement so believe that's not the issue – saira Jul 19 '16 at 20:19

1 Answers1

3

There are few things to consider. First When you declare InkCanvas you need to Let the UIElement know what input type it can expect. There are 3 commonly used types.

CoreInputDeviceTypes.Mouse ( Desktop / Notebooks without touch capability )
CoreInputDeviceTypes.Pen ( Surfacebooks and other pen enabled devices )
CoreInputDeviceTypes.Touch ( all other devices that accept Touch )

So you need to make sure these are declared on your InkCanvas.

Once done, see if your pointerevents are fired when called from XAML. If it still does not work, Try below.

CoreInkIndependentInputSource  core = CoreInkIndependentInputSource.Create(inkCanvas.InkPresenter);
core.PointerPressing += Core_PointerPressing;
core.PointerReleasing += Core_PointerReleasing;
core.PointerMoving += Core_PointerMoving;

Edit 2: Below are the methods for all 3 actions

        private void Core_PointerMoving(CoreInkIndependentInputSource sender, PointerEventArgs args)
        {
            throw new NotImplementedException();
        }

        private void Core_PointerReleasing(CoreInkIndependentInputSource sender, PointerEventArgs args)
        {
            throw new NotImplementedException();
        }

        private void Core_PointerPressing(CoreInkIndependentInputSource sender, PointerEventArgs args)
        {
            throw new NotImplementedException();
        }

Hope this helps.

AVK
  • 3,893
  • 1
  • 22
  • 31
  • how do i use `Core_PointerReleasing` ? if I use it as it is then I am getting an error at this point – saira Jul 19 '16 at 20:35
  • `No overload for 'Core_PointerReleasing' matches delegate 'TypedEventHandler' DrawingDataCollection ` this erroe – saira Jul 20 '16 at 16:33
  • I edited my answer including the 3 methods. My sample application fires all 3 methods without any issues. – AVK Jul 20 '16 at 17:38