Removed NativeHook From being used in Linux Versions
This commit is contained in:
parent
fc768ab36f
commit
026832e3f7
|
@ -1,18 +1,3 @@
|
||||||
/HelveticaNeue-UltraLight.otf
|
|
||||||
/LiberationSerif-Regular.ttf
|
|
||||||
/back.png
|
|
||||||
/basics/
|
/basics/
|
||||||
/edit.png
|
|
||||||
/guis/
|
|
||||||
/icon.ico
|
|
||||||
/icon.png
|
|
||||||
/lock.png
|
|
||||||
/main/
|
/main/
|
||||||
/manager/
|
/guis/
|
||||||
/mod_quicklaunch/
|
|
||||||
/plus.png
|
|
||||||
/save.png
|
|
||||||
/scenes/
|
|
||||||
/trash.png
|
|
||||||
/unsaved.png
|
|
||||||
/update/
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -17,6 +17,7 @@ import javafx.stage.WindowEvent;
|
||||||
import main.KeyChecker;
|
import main.KeyChecker;
|
||||||
import main.ModLoader;
|
import main.ModLoader;
|
||||||
import main.Start;
|
import main.Start;
|
||||||
|
import manager.OperatingSystem;
|
||||||
import manager.SettingManager;
|
import manager.SettingManager;
|
||||||
import scenes.MainScene;
|
import scenes.MainScene;
|
||||||
import update.Updater;
|
import update.Updater;
|
||||||
|
@ -36,6 +37,12 @@ public class BasicGuiApp extends Application{
|
||||||
ml.addMods();
|
ml.addMods();
|
||||||
ml.initMods();
|
ml.initMods();
|
||||||
|
|
||||||
|
if(SettingManager.getOperatingSystem() == OperatingSystem.WINDOWS) {
|
||||||
|
registerNativeHoook();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerNativeHoook() {
|
||||||
try {
|
try {
|
||||||
GlobalScreen.registerNativeHook();
|
GlobalScreen.registerNativeHook();
|
||||||
} catch (NativeHookException e) {
|
} catch (NativeHookException e) {
|
||||||
|
@ -49,7 +56,6 @@ public class BasicGuiApp extends Application{
|
||||||
GlobalScreen.addNativeKeyListener(listener);
|
GlobalScreen.addNativeKeyListener(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void start(Stage primaryStage) throws Exception {
|
public void start(Stage primaryStage) throws Exception {
|
||||||
|
|
||||||
mainStage = primaryStage;
|
mainStage = primaryStage;
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package guis;
|
package guis;
|
||||||
|
|
||||||
|
|
||||||
import org.jnativehook.GlobalScreen;
|
import org.jnativehook.GlobalScreen;
|
||||||
|
|
||||||
import basics.BasicGuiApp;
|
import basics.BasicGuiApp;
|
||||||
|
@ -11,19 +10,19 @@ import javafx.scene.control.CheckBox;
|
||||||
import javafx.scene.layout.AnchorPane;
|
import javafx.scene.layout.AnchorPane;
|
||||||
import javafx.scene.text.Text;
|
import javafx.scene.text.Text;
|
||||||
import main.ShortcutKeyChecker;
|
import main.ShortcutKeyChecker;
|
||||||
|
import manager.OperatingSystem;
|
||||||
import manager.ResourceManager;
|
import manager.ResourceManager;
|
||||||
import manager.SettingManager;
|
import manager.SettingManager;
|
||||||
|
|
||||||
public class SettingGui extends AnchorPane{
|
public class SettingGui extends AnchorPane {
|
||||||
|
|
||||||
|
|
||||||
AnchorPane settingPane;
|
AnchorPane settingPane;
|
||||||
|
|
||||||
public SettingGui(){
|
public SettingGui() {
|
||||||
this.setPrefWidth(300);
|
this.setPrefWidth(300);
|
||||||
this.setPrefHeight(185);
|
this.setPrefHeight(185);
|
||||||
this.setStyle("-fx-background-color: rgba(240, 240, 240, 1);");
|
this.setStyle("-fx-background-color: rgba(240, 240, 240, 1);");
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
Text setting1 = new Text("Load File.txt on startup:");
|
Text setting1 = new Text("Load File.txt on startup:");
|
||||||
setting1.setFont(ResourceManager.getFontSmall());
|
setting1.setFont(ResourceManager.getFontSmall());
|
||||||
|
@ -31,7 +30,7 @@ public class SettingGui extends AnchorPane{
|
||||||
setting1.setLayoutY(20);
|
setting1.setLayoutY(20);
|
||||||
setting1.prefWidth(170);
|
setting1.prefWidth(170);
|
||||||
setting1.prefHeight(30);
|
setting1.prefHeight(30);
|
||||||
|
|
||||||
final CheckBox setting1Box = new CheckBox();
|
final CheckBox setting1Box = new CheckBox();
|
||||||
setting1Box.setLayoutX(180);
|
setting1Box.setLayoutX(180);
|
||||||
setting1Box.setLayoutY(7);
|
setting1Box.setLayoutY(7);
|
||||||
|
@ -40,14 +39,14 @@ public class SettingGui extends AnchorPane{
|
||||||
setting1Box.setSelected(SettingManager.isLoadFileOnBoot());
|
setting1Box.setSelected(SettingManager.isLoadFileOnBoot());
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
Text setting3 = new Text("Check for updates on startup:");
|
Text setting3 = new Text("Check for updates on startup:");
|
||||||
setting3.setFont(ResourceManager.getFontSmall());
|
setting3.setFont(ResourceManager.getFontSmall());
|
||||||
setting3.setLayoutX(10);
|
setting3.setLayoutX(10);
|
||||||
setting3.setLayoutY(100);
|
setting3.setLayoutY(100);
|
||||||
setting3.prefWidth(220);
|
setting3.prefWidth(220);
|
||||||
setting3.prefHeight(30);
|
setting3.prefHeight(30);
|
||||||
|
|
||||||
final CheckBox setting3Box = new CheckBox();
|
final CheckBox setting3Box = new CheckBox();
|
||||||
setting3Box.setLayoutX(230);
|
setting3Box.setLayoutX(230);
|
||||||
setting3Box.setLayoutY(87);
|
setting3Box.setLayoutY(87);
|
||||||
|
@ -56,77 +55,80 @@ public class SettingGui extends AnchorPane{
|
||||||
setting3Box.setSelected(SettingManager.isCheckUptdateOnBoot());
|
setting3Box.setSelected(SettingManager.isCheckUptdateOnBoot());
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
Text setting4 = new Text("QuickLaunch shortcut:");
|
if (SettingManager.getOperatingSystem() == OperatingSystem.WINDOWS) {
|
||||||
setting4.setFont(ResourceManager.getFontSmall());
|
Text setting4 = new Text("QuickLaunch shortcut:");
|
||||||
setting4.setLayoutX(10);
|
setting4.setFont(ResourceManager.getFontSmall());
|
||||||
setting4.setLayoutY(128);
|
setting4.setLayoutX(10);
|
||||||
setting4.prefWidth(180);
|
setting4.setLayoutY(128);
|
||||||
setting4.prefHeight(30);
|
setting4.prefWidth(180);
|
||||||
|
setting4.prefHeight(30);
|
||||||
|
|
||||||
final Button setting4button1 = new Button("key1");
|
final Button setting4button1 = new Button("key1");
|
||||||
if(!(SettingManager.getKey1() == -1)){
|
if (!(SettingManager.getKey1() == -1)) {
|
||||||
setting4button1.setText(SettingManager.getKey1()+"");
|
setting4button1.setText(SettingManager.getKey1() + "");
|
||||||
}
|
|
||||||
setting4button1.setFont(ResourceManager.getFontSmall());
|
|
||||||
setting4button1.setLayoutX(10);
|
|
||||||
setting4button1.setLayoutY(145);
|
|
||||||
setting4button1.prefWidth(40);
|
|
||||||
setting4button1.prefHeight(24);
|
|
||||||
setting4button1.setOnAction(new EventHandler<ActionEvent>() {
|
|
||||||
|
|
||||||
|
|
||||||
public void handle(ActionEvent event) {
|
|
||||||
ShortcutKeyChecker skc = new ShortcutKeyChecker();
|
|
||||||
GlobalScreen.removeNativeKeyListener(BasicGuiApp.listener);
|
|
||||||
GlobalScreen.addNativeKeyListener(skc);
|
|
||||||
while(skc.lastKey == -1){
|
|
||||||
|
|
||||||
try {
|
|
||||||
Thread.sleep(100);
|
|
||||||
} catch (InterruptedException e1) {
|
|
||||||
e1.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setting4button1.setText(skc.lastKey+"");
|
|
||||||
SettingManager.setKey1(skc.lastKey);
|
|
||||||
GlobalScreen.removeNativeKeyListener(skc);
|
|
||||||
GlobalScreen.addNativeKeyListener(BasicGuiApp.listener);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
setting4button1.setFont(ResourceManager.getFontSmall());
|
||||||
|
setting4button1.setLayoutX(10);
|
||||||
final Button setting4button2 = new Button("key2");
|
setting4button1.setLayoutY(145);
|
||||||
if(!(SettingManager.getKey2() == -1)){
|
setting4button1.prefWidth(40);
|
||||||
setting4button2.setText(SettingManager.getKey2()+"");
|
setting4button1.prefHeight(24);
|
||||||
}
|
setting4button1.setOnAction(new EventHandler<ActionEvent>() {
|
||||||
setting4button2.setFont(ResourceManager.getFontSmall());
|
|
||||||
setting4button2.setLayoutX(95);
|
|
||||||
setting4button2.setLayoutY(145);
|
|
||||||
setting4button2.prefWidth(40);
|
|
||||||
setting4button2.prefHeight(24);
|
|
||||||
setting4button2.setOnAction(new EventHandler<ActionEvent>() {
|
|
||||||
|
|
||||||
|
public void handle(ActionEvent event) {
|
||||||
public void handle(ActionEvent event) {
|
ShortcutKeyChecker skc = new ShortcutKeyChecker();
|
||||||
ShortcutKeyChecker skc = new ShortcutKeyChecker();
|
GlobalScreen.removeNativeKeyListener(BasicGuiApp.listener);
|
||||||
GlobalScreen.removeNativeKeyListener(BasicGuiApp.listener);
|
GlobalScreen.addNativeKeyListener(skc);
|
||||||
GlobalScreen.addNativeKeyListener(skc);
|
while (skc.lastKey == -1) {
|
||||||
while(skc.lastKey == -1){
|
|
||||||
try {
|
try {
|
||||||
Thread.sleep(100);
|
Thread.sleep(100);
|
||||||
} catch (InterruptedException e1) {
|
} catch (InterruptedException e1) {
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
setting4button1.setText(skc.lastKey + "");
|
||||||
|
SettingManager.setKey1(skc.lastKey);
|
||||||
|
GlobalScreen.removeNativeKeyListener(skc);
|
||||||
|
GlobalScreen.addNativeKeyListener(BasicGuiApp.listener);
|
||||||
|
|
||||||
}
|
}
|
||||||
setting4button2.setText(skc.lastKey+"");
|
});
|
||||||
SettingManager.setKey2(skc.lastKey);
|
|
||||||
GlobalScreen.removeNativeKeyListener(skc);
|
final Button setting4button2 = new Button("key2");
|
||||||
GlobalScreen.addNativeKeyListener(BasicGuiApp.listener);
|
if (!(SettingManager.getKey2() == -1)) {
|
||||||
|
setting4button2.setText(SettingManager.getKey2() + "");
|
||||||
}
|
}
|
||||||
});
|
setting4button2.setFont(ResourceManager.getFontSmall());
|
||||||
|
setting4button2.setLayoutX(95);
|
||||||
|
setting4button2.setLayoutY(145);
|
||||||
|
setting4button2.prefWidth(40);
|
||||||
|
setting4button2.prefHeight(24);
|
||||||
|
setting4button2.setOnAction(new EventHandler<ActionEvent>() {
|
||||||
|
|
||||||
|
public void handle(ActionEvent event) {
|
||||||
|
ShortcutKeyChecker skc = new ShortcutKeyChecker();
|
||||||
|
GlobalScreen.removeNativeKeyListener(BasicGuiApp.listener);
|
||||||
|
GlobalScreen.addNativeKeyListener(skc);
|
||||||
|
while (skc.lastKey == -1) {
|
||||||
|
try {
|
||||||
|
Thread.sleep(100);
|
||||||
|
} catch (InterruptedException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setting4button2.setText(skc.lastKey + "");
|
||||||
|
SettingManager.setKey2(skc.lastKey);
|
||||||
|
GlobalScreen.removeNativeKeyListener(skc);
|
||||||
|
GlobalScreen.addNativeKeyListener(BasicGuiApp.listener);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.getChildren().add(setting4);
|
||||||
|
this.getChildren().add(setting4button1);
|
||||||
|
this.getChildren().add(setting4button2);
|
||||||
|
}
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
Button exit = new Button("Done");
|
Button exit = new Button("Done");
|
||||||
exit.setFont(ResourceManager.getFontSmall());
|
exit.setFont(ResourceManager.getFontSmall());
|
||||||
exit.setLayoutX(230);
|
exit.setLayoutX(230);
|
||||||
|
@ -135,25 +137,21 @@ public class SettingGui extends AnchorPane{
|
||||||
exit.prefHeight(24);
|
exit.prefHeight(24);
|
||||||
exit.setOnAction(new EventHandler<ActionEvent>() {
|
exit.setOnAction(new EventHandler<ActionEvent>() {
|
||||||
|
|
||||||
|
|
||||||
public void handle(ActionEvent event) {
|
public void handle(ActionEvent event) {
|
||||||
SettingManager.setLoadFileOnBoot(setting1Box.isSelected());
|
SettingManager.setLoadFileOnBoot(setting1Box.isSelected());
|
||||||
SettingManager.setCheckUptdateOnBoot(setting3Box.isSelected());
|
SettingManager.setCheckUptdateOnBoot(setting3Box.isSelected());
|
||||||
SettingManager.saveSettings();
|
SettingManager.saveSettings();
|
||||||
BasicGuiApp.mainStage.setScene(BasicGuiApp.mainScene);
|
BasicGuiApp.mainStage.setScene(BasicGuiApp.mainScene);
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
this.getChildren().add(setting1);
|
this.getChildren().add(setting1);
|
||||||
this.getChildren().add(setting1Box);
|
this.getChildren().add(setting1Box);
|
||||||
this.getChildren().add(setting3);
|
this.getChildren().add(setting3);
|
||||||
this.getChildren().add(setting3Box);
|
this.getChildren().add(setting3Box);
|
||||||
this.getChildren().add(setting4);
|
|
||||||
this.getChildren().add(setting4button1);
|
|
||||||
this.getChildren().add(setting4button2);
|
|
||||||
this.getChildren().add(exit);
|
this.getChildren().add(exit);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ import org.jnativehook.keyboard.NativeKeyListener;
|
||||||
import basics.BasicGuiApp;
|
import basics.BasicGuiApp;
|
||||||
import guis.MainGui;
|
import guis.MainGui;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import manager.OperatingSystem;
|
|
||||||
import manager.SettingManager;
|
import manager.SettingManager;
|
||||||
|
|
||||||
public class KeyChecker implements NativeKeyListener{
|
public class KeyChecker implements NativeKeyListener{
|
||||||
|
@ -30,32 +29,13 @@ public class KeyChecker implements NativeKeyListener{
|
||||||
//Workaround because toFront() does not work and makes window active
|
//Workaround because toFront() does not work and makes window active
|
||||||
Platform.runLater(new Runnable() {
|
Platform.runLater(new Runnable() {
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
if(SettingManager.getOperatingSystem() == OperatingSystem.LINUX) {
|
|
||||||
BasicGuiApp.mainStage.setIconified(true);
|
|
||||||
BasicGuiApp.mainStage.setIconified(false);
|
|
||||||
BasicGuiApp.mainStage.toFront();
|
|
||||||
BasicGuiApp.mainStage.requestFocus();
|
|
||||||
MainGui.inputField.requestFocus();
|
|
||||||
}
|
|
||||||
else if(SettingManager.getOperatingSystem() == OperatingSystem.WINDOWS) {
|
|
||||||
BasicGuiApp.mainStage.setAlwaysOnTop(true);
|
BasicGuiApp.mainStage.setAlwaysOnTop(true);
|
||||||
BasicGuiApp.mainStage.setAlwaysOnTop(false);
|
BasicGuiApp.mainStage.setAlwaysOnTop(false);
|
||||||
BasicGuiApp.mainStage.requestFocus();
|
BasicGuiApp.mainStage.requestFocus();
|
||||||
MainGui.inputField.requestFocus();
|
MainGui.inputField.requestFocus();
|
||||||
BasicGuiApp.mainStage.setIconified(true);
|
BasicGuiApp.mainStage.setIconified(true);
|
||||||
BasicGuiApp.mainStage.setIconified(false);
|
BasicGuiApp.mainStage.setIconified(false);
|
||||||
}
|
|
||||||
else if(SettingManager.getOperatingSystem() == OperatingSystem.OSX) {
|
|
||||||
BasicGuiApp.mainStage.setIconified(true);
|
|
||||||
BasicGuiApp.mainStage.setIconified(false);
|
|
||||||
BasicGuiApp.mainStage.toFront();
|
|
||||||
BasicGuiApp.mainStage.requestFocus();
|
|
||||||
MainGui.inputField.requestFocus();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue