mirror of
https://github.com/2OOP/pism.git
synced 2026-02-04 02:44:50 +00:00
Escape remove popup
This commit is contained in:
@@ -5,7 +5,6 @@ import javafx.scene.input.KeyCode;
|
|||||||
import javafx.scene.input.KeyEvent;
|
import javafx.scene.input.KeyEvent;
|
||||||
|
|
||||||
import org.toop.app.widget.Primitive;
|
import org.toop.app.widget.Primitive;
|
||||||
import org.toop.app.widget.Widget;
|
|
||||||
import org.toop.app.widget.WidgetContainer;
|
import org.toop.app.widget.WidgetContainer;
|
||||||
import org.toop.app.widget.complex.LoadingWidget;
|
import org.toop.app.widget.complex.LoadingWidget;
|
||||||
import org.toop.app.widget.display.SongDisplay;
|
import org.toop.app.widget.display.SongDisplay;
|
||||||
@@ -39,9 +38,6 @@ public final class App extends Application {
|
|||||||
private static int height;
|
private static int height;
|
||||||
private static int width;
|
private static int width;
|
||||||
|
|
||||||
private static boolean isEscActive; // TODO kut variable
|
|
||||||
private static EscapePopup escPopup; // TODO kut variable
|
|
||||||
|
|
||||||
public static void run(String[] args) {
|
public static void run(String[] args) {
|
||||||
launch(args);
|
launch(args);
|
||||||
}
|
}
|
||||||
@@ -142,14 +138,16 @@ public final class App extends Application {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void escapePopup() {
|
public void escapePopup() {
|
||||||
if (App.escPopup == null) App.escPopup = new EscapePopup();
|
if (WidgetContainer.getAllWidgets().stream().anyMatch(
|
||||||
if (!App.isEscActive) {
|
e -> e instanceof QuitPopup || e instanceof EscapePopup
|
||||||
App.isEscActive = true;
|
)) {
|
||||||
escPopup.show(Pos.CENTER);
|
WidgetContainer.findRemove(QuitPopup.class);
|
||||||
} else {
|
WidgetContainer.findRemove(EscapePopup.class);
|
||||||
escPopup.hide();
|
return;
|
||||||
App.isEscActive = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EscapePopup escPopup = new EscapePopup();
|
||||||
|
escPopup.show(Pos.CENTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setOnLoadingSuccess(LoadingWidget loading) {
|
private void setOnLoadingSuccess(LoadingWidget loading) {
|
||||||
@@ -163,15 +161,10 @@ public final class App extends Application {
|
|||||||
stage.setOnCloseRequest(event -> {
|
stage.setOnCloseRequest(event -> {
|
||||||
event.consume();
|
event.consume();
|
||||||
|
|
||||||
var abc = WidgetContainer.getAllWidgets();
|
|
||||||
for (Widget widget : abc) {
|
|
||||||
IO.println(widget.getClass().getSimpleName());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (WidgetContainer.getAllWidgets().stream().anyMatch(e -> e instanceof QuitPopup)) return;
|
if (WidgetContainer.getAllWidgets().stream().anyMatch(e -> e instanceof QuitPopup)) return;
|
||||||
|
|
||||||
var a = new QuitPopup();
|
QuitPopup a = new QuitPopup();
|
||||||
a.show(Pos.CENTER); // TODO disable allow having multiple
|
a.show(Pos.CENTER);
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -62,6 +62,14 @@ public final class WidgetContainer {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void findRemove(Class<? extends Widget> widgetClass) {
|
||||||
|
if (root == null || currentView == null) return;
|
||||||
|
|
||||||
|
Platform.runLater(() ->
|
||||||
|
currentView.getChildren().removeIf(widget -> widget.getClass().isAssignableFrom(widgetClass))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public static ViewWidget getCurrentView() {
|
public static ViewWidget getCurrentView() {
|
||||||
return currentView;
|
return currentView;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user