https://kotlinlang.org logo
#compose-desktop
Title
# compose-desktop
a

Aleksandrs Vitjukovs

10/27/2023, 6:25 PM
Alternatively, what's a good way to intercept Ctrl+Z app-wide? If we have to work with the
KeyEvent
API (
Modifier.onKeyEvent
/
onPreviewKeyEvent
), is there a nice high level way to detect an "Undo" as opposed to Ctrl+Z / Meta+Z? And finally, what's a good cross-platform way of detecting Ctrl/Cmd+Key? I'm currently checking OS via
System.getProperty
and looking for a matching modifier key.
k

Kirill Grouchnikov

10/27/2023, 7:19 PM
It’s not just the modifier key. Different platforms do have different key combinations for the “same” action.
See Aqua / macOS key bindings in JDK for example - https://github.com/openjdk/jdk/blob/d2260146c9930002e430a874f2585d699dedc155/src/java.desktop/macosx/classes/com/apple/laf/AquaKeyBindings.java - these are defined as explicit key combinations, and not just a “global” modifier override.
Versus https://github.com/openjdk/jdk/blob/d2260146c9930002e430a874f2585d699dedc155/src/j[…]va.desktop/share/classes/sun/swing/plaf/WindowsKeybindings.java (and the same for Gtk). Some bindings exist only for one platform, where relevant (in Aqua there are more text navigation actions, for example)
gratitude thank you 1
2 Views