Commit ae42d1c2 authored by Martin Slind Hagen's avatar Martin Slind Hagen 🏑 Committed by Hermann Owren Elton
Browse files

Added functionality to exit pop up window with keyboard

parent a29a6bb0
......@@ -5,6 +5,7 @@ import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.input.KeyCode;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
......@@ -47,6 +48,13 @@ public final class PopUpWindow {
DIALOG_VBOX.getChildren().addAll(DIALOG_TEXT, DIALOG_HBOX);
Scene dialogScene = new Scene(DIALOG_VBOX, width, height);
//Sets the escape key to run the closeProgram method
dialogScene.setOnKeyPressed(e -> {
if (e.getCode() == KeyCode.ESCAPE) {
DIALOG_WINDOW.close();
}
});
DIALOG_WINDOW.setScene(dialogScene);
DIALOG_WINDOW.show();
}
......
......@@ -162,7 +162,7 @@ final class PhotosRoot extends SceneRoot {
*/
private void setupAlbumButtons() {
Css.setButton(700, 25, 20, ADD_TO_ALBUM_BUTTON);
ADD_TO_ALBUM_BUTTON.setOnAction(s -> createNewAlbumButtonPressed());
ADD_TO_ALBUM_BUTTON.setOnAction(s -> addToAlbumPressed());
if (UserInfo.getUser().getAlbums().isEmpty()) {
ADD_TO_ALBUM_BUTTON.setDisable(true);
}
......@@ -224,7 +224,7 @@ final class PhotosRoot extends SceneRoot {
* Method that creates the popup that can create albums and creates the action popup
* Used in setupAlbumButtons
*/
private void createNewAlbumButtonPressed() {
private void addToAlbumPressed() {
PopUpWindow popupWindow = new PopUpWindow(ApplicationManager.getStage(), 500, 100);
popupWindow.getDialogWindow().setTitle("Add to album");
popupWindow.getDialogText().setText("Please select the name of the album:");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment