mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-17 10:11:27 +00:00
request focus on password field after selecting a vault
This commit is contained in:
@@ -119,6 +119,11 @@ public class ChangePasswordController implements ViewController {
|
||||
return root;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void focus() {
|
||||
oldPasswordField.requestFocus();
|
||||
}
|
||||
|
||||
void setVault(Vault vault) {
|
||||
this.vault = Objects.requireNonNull(vault);
|
||||
// trigger "default" change to refresh key bindings:
|
||||
|
||||
@@ -105,6 +105,11 @@ public class InitializeController implements ViewController {
|
||||
return root;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void focus() {
|
||||
passwordField.requestFocus();
|
||||
}
|
||||
|
||||
void setVault(Vault vault) {
|
||||
this.vault = Objects.requireNonNull(vault);
|
||||
// trigger "default" change to refresh key bindings:
|
||||
|
||||
@@ -72,6 +72,9 @@ import javafx.scene.control.ListView;
|
||||
import javafx.scene.control.MenuItem;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.input.KeyCode;
|
||||
import javafx.scene.input.KeyEvent;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.text.Font;
|
||||
@@ -165,6 +168,7 @@ public class MainController implements ViewController {
|
||||
@Override
|
||||
public void initialize() {
|
||||
vaultList.setItems(vaults);
|
||||
vaultList.setOnKeyPressed(this::didPressKeyOnList);
|
||||
vaultList.setCellFactory(this::createDirecoryListCell);
|
||||
activeController.set(viewControllerLoader.load("/fxml/welcome.fxml"));
|
||||
selectedVault.bind(vaultList.getSelectionModel().selectedItemProperty());
|
||||
@@ -239,6 +243,7 @@ public class MainController implements ViewController {
|
||||
private ListCell<Vault> createDirecoryListCell(ListView<Vault> param) {
|
||||
final DirectoryListCell cell = new DirectoryListCell();
|
||||
cell.setVaultContextMenu(vaultListCellContextMenu);
|
||||
cell.setOnMouseClicked(this::didClickOnListCell);
|
||||
return cell;
|
||||
}
|
||||
|
||||
@@ -393,6 +398,19 @@ public class MainController implements ViewController {
|
||||
}
|
||||
}
|
||||
|
||||
private void didPressKeyOnList(KeyEvent e) {
|
||||
if (e.getCode() == KeyCode.ENTER || e.getCode() == KeyCode.SPACE) {
|
||||
activeController.get().focus();
|
||||
}
|
||||
}
|
||||
|
||||
private void didClickOnListCell(MouseEvent e) {
|
||||
if (MouseEvent.MOUSE_CLICKED.equals(e.getEventType()) && e.getSource() instanceof DirectoryListCell) {
|
||||
assert ((DirectoryListCell) e.getSource()).isSelected() : "click event occurs after mousedown, which causes selection of cell";
|
||||
activeController.get().focus();
|
||||
}
|
||||
}
|
||||
|
||||
// ****************************************
|
||||
// Public Bindings
|
||||
// ****************************************
|
||||
@@ -471,6 +489,7 @@ public class MainController implements ViewController {
|
||||
ctrl.setVault(selectedVault.get());
|
||||
ctrl.setListener(this::didChangePassword);
|
||||
activeController.set(ctrl);
|
||||
Platform.runLater(ctrl::focus);
|
||||
}
|
||||
|
||||
public void didChangePassword() {
|
||||
|
||||
@@ -155,6 +155,11 @@ public class UnlockController implements ViewController {
|
||||
return root;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void focus() {
|
||||
passwordField.requestFocus();
|
||||
}
|
||||
|
||||
void setVault(Vault vault) {
|
||||
vaultSubs.unsubscribe();
|
||||
vaultSubs = Subscription.EMPTY;
|
||||
|
||||
@@ -84,6 +84,11 @@ public class UpgradeController implements ViewController {
|
||||
return root;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void focus() {
|
||||
passwordField.requestFocus();
|
||||
}
|
||||
|
||||
void setVault(Vault vault) {
|
||||
this.vault = Objects.requireNonNull(vault);
|
||||
errorLabel.setText(null);
|
||||
|
||||
@@ -24,4 +24,8 @@ public interface ViewController extends Initializable {
|
||||
// no-op
|
||||
}
|
||||
|
||||
default void focus() {
|
||||
// no-op
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user