Fix keybindings in entry editor#2971
Conversation
Try to match awt key events with keycombinations
Remove + signs to make swing work again Add + sign only in binding checker
| //We need to consume this event here to prevent the propgation of keybinding events back to the JFrame | ||
|
|
||
| e.consume(); | ||
| Optional<KeyCode> keyCode = Arrays.stream(KeyCode.values()).filter(k -> k.getName().equals(e.getKeyText(e.getKeyCode()))).findFirst(); |
There was a problem hiding this comment.
Can you please encapsulate this code in a Optional<KeyBinding> KeyPrefs#mapToKeyBinding method that accepts a awt.KeyEvent.
| case CLOSE_ENTRY_EDITOR: | ||
| case DELETE_ENTRY: | ||
| case SELECT_ALL: | ||
| e.consume(); |
There was a problem hiding this comment.
Do we really have to handle these events on the swing side? Does it not suffice to consume them at
?There was a problem hiding this comment.
Yes, unfortunately. Although the event is consumed it is still catched by the swing side and executed.
I have found no way to stop this.
There was a problem hiding this comment.
Good to know. In my opinion this is a bug in the FXPanel.
|
|
||
| private KeyCombination getKeyCombination(KeyBinding bindName) { | ||
| String binding = get(bindName.getConstant()); | ||
| binding = binding.replaceAll(" ", "+"); //javafdx expects plus signs between modifiers, swing not |
There was a problem hiding this comment.
I would actually prefer it the other way around: store it in JavaFX format and replace "+" -> " " for swing since we want to completely switch to FX at some point.
|
|
||
| @Test | ||
| public void testConversionAwtKeyEventJavafxKeyEvent() { | ||
| java.awt.event.KeyEvent evt = new java.awt.event.KeyEvent(mock(JFrame.class), 0, 0, InputEvent.CTRL_MASK, java.awt.event.KeyEvent.VK_S, java.awt.event.KeyEvent.CHAR_UNDEFINED); |
There was a problem hiding this comment.
Reuse the method I suggested to introduce above.
Adapt test Add + between keybindings
|
I readded the plus signs between. To make it work in entry editor and swing the keybindings have to be reset once/or just set new |
Would it be possible to automate this as a preferences migration? |
|
Yeah, I also thought about that.
In fact it's just a simple find and replace
Replace modifier followed by whitespace with modifier followed by plus sign
Am 06.07.2017 10:40 nachm. schrieb "Matthias Geiger" <
notifications@github.com>:
… To make it work in entry editor and swing the keybindings have to be reset
once/or just set new
Would it be possible to automate this as a preferences migration?
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#2971 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AATi5AqVQWY2tIRoVV7Z3QywL95PLCn-ks5sLUZOgaJpZM4OOQVG>
.
|
* upstream/master: Eclipse J Add switch indentation for Eclipse and add some new missing formatting options Check for different editions in the duplicate check (#2991) Add CheckStyle Check for Constants (final static) (#2992) Add Remove link context menu entry in file editor (#2972) Fix DiVA tests Remove <pre> tag from entries fetched using MathSciNet (#2990) Fix Brazilian Portugese language loading (#2981) Use sftp's symlink command to provide symlink to latest version Update gradle from 4.0 to 4.0.1 Fix group storage (#2978) Fix keybindings in entry editor (#2971)
Awt key events are now converted to javafx key event and some events are filtered out, like copy, paste, cut, close editor, the rest is now propagated back to the jframe
Fix for #2949
gradle localizationUpdate?