locked
MS Stylus pen sample not working (only with mouse)

    Question

  • For a business form I want to add the option to add a signature by using the Styles pen (brand Bamboo) bought with the Surface (1 RT) . A sample which should do that is http://code.msdn.microsoft.com/windowsapps/Input-simplified-ink-sample-11614bbf

    It works with a Canvas control and InkCanvas_PointerPressed/PointerMoved/PointerReleased event handlers and works fine when I use it with a mouse (keeping the left mouse button pressed). However, it does not draw with the Stylus (sometimes a bit, then it draws a small line).  Basically, the Stylus moves/scrolls the window within the scrollbars. It's the same when I would try it with touch. The stylus does not have any keys (like a right mouse key button I had on a Surface (1 Pro) stylus).

    What should I do to get a Stylus working? It does work fine on e.g. the drawing option in OneNote or Windows Paint

    Wednesday, July 16, 2014 2:08 PM

Answers

  • The easiest is to set EventIsInk to always return true. If you don't care about selection, erase, etc. you don't need that complexity.

    To clarify on "I don't need touch b.t.w.", you do need touch. Your "stylus" is not a pen and does not provide pen input. Using it is the same as using your finger.

    If you want pen input you will need a device (such as a Surface Pro) which includes pen support.

    --Rob

    Thursday, July 17, 2014 8:07 PM
    Owner

All replies

  • The Surface RT doesn't have real stylus support. The pen you have acts as a touch point and the sample uses touch for manipulation rather than drawing.

    If you modify the sample to draw on touch then it should work with your stylus.

    --Rob

    Wednesday, July 16, 2014 3:25 PM
    Owner
  • Thank you Rob for your quick reply. Could you point me to a working sample, or some description of how to draw on touch or what to change in the Canvas examples? It's frankly quite disappointing to find a couple of (Microsoft and other) samples telling that you can use touch and stylus, I would say a basic requirement if one buys a Surface (any), and then find out that all examples and docs are based on using a Canvas and nor touch nor stylus work. E.g.

    https://software.intel.com/en-us/articles/mixing-stylus-and-touch-input-on-windows-8 claims it should work on every tablet. Anyhow, I hope I can fix it if you or anyone else could give some more info how to proceed.

    Dick

    Wednesday, July 16, 2014 9:41 PM
  • Surface RT does not have pen support and is not advertised as having pen support. The Surface Pro series includes pen support.

    Your add-on capacitive pointer is a touch pointer and does not provide pen input. It provides touch input.

    If you look in the sample's helper.cs file you can see its EventIsInk, EventIsErase, and EventIsSelect functions look at the pointer event's PointerDeviceType and use only Pen and Mouse input, not Touch. You can edit that to accept Touch input if that is necessary for your scenario.

    --Rob

    Wednesday, July 16, 2014 10:05 PM
    Owner
  • Hello Rob,

    I modified the 3 helper events you mentioned by adding

    || (e.Pointer.PointerDeviceType == Windows.Devices.Input.

    PointerDeviceType.Touch)

    in the middle (see below). But the control still doesn't react on touch or this stylus pen. What did I miss? I don't need touch b.t.w., I just want the stylus to work as it does in Paint or in OneNote. There must be a way but which?

    Dick

      

    boolrval = false


                || (e.Pointer.PointerDeviceType == Windows.Devices.Input.

    PointerDeviceType.Pen && pointerProperties.IsBarrelButtonPressed)

    || (e.Pointer.PointerDeviceType == Windows.Devices.Input.

    PointerDeviceType.Touch)

                || (e.Pointer.PointerDeviceType == Windows.Devices.Input.

    PointerDeviceType.Mouse && pointerProperties.IsLeftButtonPressed && e.KeyModifiers == Windows.System.VirtualKeyModifiers.Control);

           

    returnrval;

    Thursday, July 17, 2014 1:07 PM
  • The easiest is to set EventIsInk to always return true. If you don't care about selection, erase, etc. you don't need that complexity.

    To clarify on "I don't need touch b.t.w.", you do need touch. Your "stylus" is not a pen and does not provide pen input. Using it is the same as using your finger.

    If you want pen input you will need a device (such as a Surface Pro) which includes pen support.

    --Rob

    Thursday, July 17, 2014 8:07 PM
    Owner
  • Hello Rob,

    I've tried your suggestion, EventIsInk now returns true, with the sample I mentioned above, but apart from a brief few dots with touch, it doesn't do anything. Also not with the mouse + left button.

    Once again: Microsoft Paint DOES work in this very same Surface RT. With Mouse + left button, the unsuitable stylus and my fingers! So there must be a technique/control which works. If anyone knows which or how, that would be great.

    Friday, August 1, 2014 4:12 PM
  • Paint isn't using the InkManager and isn't filtering pointer events based on input type. If you just want to draw along with the pointer like Paint does you don't need to use the InkManager.

    The sample is using (and demonstrating) the InkManager and does filter the pointer events based on input type. If you want to convert input to strokes and possibly recognize it then you need the InkManager. Filtering based on event type is up to you: your "stylus" produces touch input rather than pen input, so (unlike the sample) you need to pass touch input to the InkControl to use the stylus.

    --Rob

    Thursday, August 7, 2014 11:37 PM
    Owner