From dbf69c7cc173f59fe4a5fec32f1d33df6f4b3c54 Mon Sep 17 00:00:00 2001 From: DieGurke Date: Sun, 23 Aug 2020 17:11:41 +0200 Subject: [PATCH] Implemented BackButton functionality --- .../java/envoy/client/event/BackEvent.java | 19 +++++++++++++++++++ .../envoy/client/ui/controller/ChatScene.java | 6 +++++- .../ui/controller/ContactSearchTab.java | 11 +++-------- .../main/resources/fxml/ContactSearchTab.fxml | 8 ++------ 4 files changed, 29 insertions(+), 15 deletions(-) create mode 100644 client/src/main/java/envoy/client/event/BackEvent.java diff --git a/client/src/main/java/envoy/client/event/BackEvent.java b/client/src/main/java/envoy/client/event/BackEvent.java new file mode 100644 index 0000000..3394f38 --- /dev/null +++ b/client/src/main/java/envoy/client/event/BackEvent.java @@ -0,0 +1,19 @@ +package envoy.client.event; + +import envoy.event.Event.Valueless; + +/** + * Project: client
+ * File: BackEvent.java
+ * Created: Aug 23, 2020
+ * + * @author Maximilian Käfer + * @since Envoy Client v0.2-beta + */ +public class BackEvent extends Valueless{ + + private static final long serialVersionUID = 0L; + + public BackEvent() { super(); } + +} diff --git a/client/src/main/java/envoy/client/ui/controller/ChatScene.java b/client/src/main/java/envoy/client/ui/controller/ChatScene.java index 3536603..251dec7 100644 --- a/client/src/main/java/envoy/client/ui/controller/ChatScene.java +++ b/client/src/main/java/envoy/client/ui/controller/ChatScene.java @@ -40,6 +40,7 @@ import envoy.client.data.*; import envoy.client.data.audio.AudioRecorder; import envoy.client.data.commands.SystemCommandBuilder; import envoy.client.data.commands.SystemCommandsMap; +import envoy.client.event.BackEvent; import envoy.client.event.MessageCreationEvent; import envoy.client.event.SendEvent; import envoy.client.net.Client; @@ -186,7 +187,10 @@ public final class ChatScene implements Restorable { } catch (Exception e2) { e2.printStackTrace(); } - + + //Listen to backEvents + eventBus.register(BackEvent.class, e -> tabPane.getSelectionModel().select(0)); + // Listen to received messages eventBus.register(MessageCreationEvent.class, e -> { final var message = e.get(); diff --git a/client/src/main/java/envoy/client/ui/controller/ContactSearchTab.java b/client/src/main/java/envoy/client/ui/controller/ContactSearchTab.java index 7d5f8b1..22b16e0 100644 --- a/client/src/main/java/envoy/client/ui/controller/ContactSearchTab.java +++ b/client/src/main/java/envoy/client/ui/controller/ContactSearchTab.java @@ -10,6 +10,7 @@ import javafx.scene.control.*; import javafx.scene.control.Alert.AlertType; import envoy.client.data.LocalDB; +import envoy.client.event.BackEvent; import envoy.client.event.SendEvent; import envoy.client.ui.ClearableTextField; import envoy.client.ui.SceneContext; @@ -139,12 +140,6 @@ public class ContactSearchTab { } } -// @FXML -// private void newGroupButtonClicked() { -// sceneContext.load(SceneContext.SceneInfo.GROUP_CREATION_SCENE); -// sceneContext.getController().initializeData(sceneContext, localDB); -// } - -// @FXML -// private void backButtonClicked() { sceneContext.pop(); } + @FXML + private void backButtonClicked() { eventBus.dispatch(new BackEvent()); } } diff --git a/client/src/main/resources/fxml/ContactSearchTab.fxml b/client/src/main/resources/fxml/ContactSearchTab.fxml index 4544a28..93c1ca4 100644 --- a/client/src/main/resources/fxml/ContactSearchTab.fxml +++ b/client/src/main/resources/fxml/ContactSearchTab.fxml @@ -37,7 +37,7 @@ -