Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/keenwrite.git

MainWindow: workaround for annoying menubar behaviour When switching to another app with Alt+Tab the menubar gets 'focus', but does not loose it when switching back to JavaFX app. The editor seems to have focus too (blinking caret). Pressing keys enters text to the editor, but pressing arrow keys navigates in the menubar...

AuthorKarl Tauber <email>
Date2015-08-04 11:09:39 GMT+0200
Commit720ca483fe2a2f0308fae706cd08d97bed105038
Parent51cd0c6
Delta11 lines added, 0 lines removed, 11-line increase
src/main/java/org/markdownwriterfx/MainWindow.java
import javafx.scene.control.MenuItem;
import javafx.scene.control.ToolBar;
+import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyCombination;
import javafx.scene.input.KeyEvent;
if (!fileEditorTabPane.closeAllEditors())
e.consume();
+ });
+
+ // workaround for a bug in JavaFX: unselect menubar if window looses focus
+ newWindow.focusedProperty().addListener((obs, oldFocused, newFocused) -> {
+ if (!newFocused) {
+ // send an ESC key event to the menubar
+ menuBar.fireEvent(new KeyEvent(KeyEvent.KEY_PRESSED,
+ KeyEvent.CHAR_UNDEFINED, "", KeyCode.ESCAPE,
+ false, false, false, false));
+ }
});
});