SkiaSharp icon indicating copy to clipboard operation
SkiaSharp copied to clipboard

[BUG] SkiaSharp views do not emit mouse motion events when a mouse button is not clicked

Open ylatuya opened this issue 6 years ago • 3 comments

On platforms with a mouse, the only way to track mouse motion is through the Touch events and it only happens when a mouse key is pressed. In many uses cases you still need the mouse motion without any of the mouse keys pressed, for example to prelight objects. For now I have reproduce this error in the Forms views.

From the SKTouchEventArgs API I understand this could be achieved emitting the motion event with the InContact property to false, am I correct? Otherwise this would be a feature instead of bug :)

ylatuya avatar Feb 28 '19 15:02 ylatuya

What platforms are broken? Do you get any events when the mouse moves? I believe it was working, maybe something broke.

It may be that you did not set e.Handled = true. If you don't let the OS know that your are interested in the event, then it won't send the rest.

mattleibow avatar Feb 28 '19 20:02 mattleibow

I do get move events when moving the mouse, but only when a button is pressed. This happens with the SkiaSharp.Views.Forms.SKCanvasView in macOS and in the Android and iOS emulators. I can't remind right now from other applications I wrote, if Android.View or UIKit.UIView emit those events, but in macOS it should.

Here is the code: https://github.com/ylatuya/lienzosharp/blob/master/src/LienzoSharp.Skia.Forms/LienzoFormsView.cs#L104

Looking at the implementation, at least for the macOS/iOS part, it seems it's only handling mouse drag events: https://github.com/mono/SkiaSharp/blob/master/source/SkiaSharp.Views.Forms/SkiaSharp.Views.Forms.Mac/SKTouchHandler.cs

ylatuya avatar Mar 05 '19 17:03 ylatuya

I know this is an old issue, but still valid. Currently the macOS views use a gesture recognizer - which only works when the mouse is pressed.

A better alternative is to override the mouse events on the view itself and/or use a NSTrackingArea.

mattleibow avatar Apr 26 '20 05:04 mattleibow