This commit is contained in:
Gabriel Tofvesson 2016-11-04 21:02:18 +01:00
parent b741ab636d
commit 95e9dca367
2 changed files with 6 additions and 5 deletions

Binary file not shown.

View File

@ -37,6 +37,7 @@ public class Main extends Application {
private Rectangle dragBar; // Draggable top bar private Rectangle dragBar; // Draggable top bar
private Pane root, tab; private Pane root, tab;
private Tabs activeTab = Tabs.Home; private Tabs activeTab = Tabs.Home;
Async stringUpdater;
@Override @Override
public void start(Stage primaryStage) throws Exception{ public void start(Stage primaryStage) throws Exception{
@ -80,8 +81,10 @@ public class Main extends Application {
Modpack_btn.setOnMouseClicked(event ->{ Modpack_btn.setOnMouseClicked(event ->{
if(activeTab!=Tabs.Modpacks){ if(activeTab!=Tabs.Modpacks){
if(stringUpdater!=null && stringUpdater.isAlive()) stringUpdater.cancel();
(activeTab=Tabs.Modpacks).switchTab(tab); // Sets the active tab to the modpacks tab unless it's already active (activeTab=Tabs.Modpacks).switchTab(tab); // Sets the active tab to the modpacks tab unless it's already active
//TODO: Create a dynamic updating string from the input ( Text Field ) //TODO: Create a dynamic updating string from the input ( Text Field )
stringUpdater = new Async(SafeReflection.getFirstMethod(Main.class, "detectStringUpdate"), Tabs.Modpacks.loaded.lookup("#search-modpacks"));
} }
}); });
@ -93,9 +96,6 @@ public class Main extends Application {
}); });
Async a = new Async(null, SafeReflection.getMethod(getClass(), "run", (Class<?>[]) null), null);
System.out.println(a.await());
// Drag // Drag
dragBar.setOnMousePressed(event -> { dragBar.setOnMousePressed(event -> {
xOffset = event.getSceneX(); xOffset = event.getSceneX();
@ -116,8 +116,9 @@ public class Main extends Application {
launch(args); launch(args);
} }
public static int run(){ public static void detectStringUpdate(TextField toRead){
return 1500; String s = "";
while(true) if(!s.equals(toRead.getText())) System.out.println(s = toRead.getText());
} }
} }