Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update event modifiers on drag and drop events. #830

Merged
merged 1 commit into from May 20, 2023

Conversation

castano
Copy link
Contributor

@castano castano commented May 11, 2023

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

@floooh
Copy link
Owner

floooh commented May 11, 2023

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

@castano
Copy link
Contributor Author

castano commented May 11, 2023

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
Copy link
Owner

floooh commented May 20, 2023

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
Copy link
Owner

floooh commented May 20, 2023

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

  • set dx/dy to zero in SAPP_EVENTTYPE_MOUSE_ENTER/LEAVE:
    • macos
    • emsc
    • linux
    • win32
  • set mouse-pos in SAPP_EVENTTYPES_FILES_DROPPED:
    • macos (previously this was the drag-start pos outside the window)
    • emsc (was already working)
    • linux (was already working)
    • win32 (was already working)
  • dx/dy should be zero in SAPP_EVENTTYPES_FILES_DROPPED:
    • macos
    • emsc (was already working)
    • linux
    • win32 (was already working)
  • set modifier keys in SAPP_EVENTTYPE_FILES_DROPPED:
    • macos
    • emsc
    • linux
    • win32 (already in PR)

...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 floooh merged commit be6c770 into floooh:master May 20, 2023
25 checks passed
@floooh
Copy link
Owner

floooh commented May 20, 2023

Ok merged. Many thanks for the PR!

@castano
Copy link
Contributor Author

castano commented May 24, 2023

Awesome, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants