Skip to content

expose mouse button and modifiers from underlying AWT mouse event#41

Open
dandrake wants to merge 1 commit into
mainfrom
mouse-button-events
Open

expose mouse button and modifiers from underlying AWT mouse event#41
dandrake wants to merge 1 commit into
mainfrom
mouse-button-events

Conversation

@dandrake

@dandrake dandrake commented Dec 5, 2025

Copy link
Copy Markdown

Fixes #28.

We now have getButton and getModifiers methods and some associated constants. I also added in getEventId, though that looks to InputEvent.getModifiers which was deprecated a very, very long time ago; we should consider changing that to use getModifiersEx.

@dandrake

dandrake commented Dec 5, 2025

Copy link
Copy Markdown
Author

I tested this and it works as expected. I am looking for feedback on several bits, though:

  • I copied over a bunch of the constants from MouseEvent; on the other hand, users can access those with MouseEvent.BLAH and similar. But maybe that's too confusing -- they won't have a good notion of the difference between Kilt's MouseButtonEvent and the AWT MouseEvent.

  • I also expose the modifiers, but those are bitmasks and correctly interpreting them using & and | operators will be tricky for students. OTOH I don't think many of them will ever need or want to do that kind of handling.

  • I also expose the event ID, but I'm not sure if that'll be useful.

@dandrake

dandrake commented Dec 5, 2025

Copy link
Copy Markdown
Author

For the failing regression tests -- on my Mac, I got that error and fixed it by changing the required Java version from 17 to 21. Looks like the failing tests did so because they do have version 17 -- do we need to still support that? I suspect so, but...maybe not?

Fixes #28. We now have `getButton` and `getModifiers` methods and some
associated constants for the buttons, events, and modifier key masks. I
also added in `getEventId`, though that looks to
`InputEvent.getModifiers` which was deprecated a very, very long time
ago; we should consider changing that to use `getModifiersEx`.
@dandrake dandrake force-pushed the mouse-button-events branch from 300a624 to 1c28bd7 Compare December 8, 2025 21:27
@dandrake

dandrake commented Dec 8, 2025

Copy link
Copy Markdown
Author

Per Paul's comment, it seems our approach is to suppress as much of the underlying AWT stuff as possible. So it seems fine to copy over all the event, button, and mask constants.

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.

CanvasWindow.onClick() should have right click identification feature

1 participant