floooh / sokol

minimal cross-platform standalone C headers
https://floooh.github.io/sokol-html5
zlib License
7.04k stars 494 forks source link

Update event modifiers on drag and drop events. #830

Closed castano closed 1 year ago

castano commented 1 year ago

In order to detect if any modifier keys are being pressed at the end of a drop event.

floooh commented 1 year ago

This is a good change, but I'll need to check if this fix is also needed on macOS and Linux.

castano commented 1 year ago

I don't know about Linux, but this certainly needs more work on MacOS. There's no NSEvent object available in the drop event handler, so it wasn't immediately obvious how to update the modifiers. It should not be hard to set these based on the most recent value, though.

floooh commented 1 year ago

Starting to look into this now.

macOS seems to have a class-method (aka static method) on NSEvent which provides the current event mask without requiring an actual event object: https://developer.apple.com/documentation/appkit/nsevent/1535211-modifierflags?language=objc

floooh commented 1 year ago

I'm doing a few slightly related fixes in my merge-branch, notes to self:

...hmm, I can't find a way to get modifier key state in Xlib. The dropped-event doesn't have this info, and polling the current keyboard state always returns that no keys are pressed. Added a fixme-comment for now, but this might not be a feature to rely on in cross-platform apps.

floooh commented 1 year ago

Ok merged. Many thanks for the PR!

castano commented 1 year ago

Awesome, thanks!