Skip to content

Commit

Permalink
Force window to top when navigated to
Browse files Browse the repository at this point in the history
  • Loading branch information
Col-E committed Mar 6, 2024
1 parent 71903e1 commit 886b844
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import javafx.scene.control.Menu;
import javafx.scene.control.MenuItem;
import javafx.scene.control.Tab;
import javafx.stage.Stage;
import javafx.stage.Window;
import org.kordamp.ikonli.carbonicons.CarbonIcons;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
Expand Down Expand Up @@ -1925,7 +1927,14 @@ private static void selectTab(Navigable navigable) {
for (DockingTab tab : tabParent.getDockTabs())
if (tab.getContent() == node) {
tab.select();
scene.getWindow().requestFocus();
Window window = scene.getWindow();
if (window instanceof Stage stage){
// The method 'stage.toFront()' does not work as you'd expect so this hack is how we
// force the window to the front.
stage.setAlwaysOnTop(true);
stage.setAlwaysOnTop(false);
}
window.requestFocus();
return;
}
}
Expand Down

0 comments on commit 886b844

Please sign in to comment.