mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-21 23:20:23 +00:00
Input fixes
This commit is contained in:
parent
8ea0f98ae9
commit
97d9e7e6a1
6 changed files with 23 additions and 45 deletions
|
@ -135,7 +135,7 @@ public final class BrowserFileListComp extends SimpleComp {
|
|||
|
||||
private void prepareTypedSelectionModel(TableView<BrowserEntry> table) {
|
||||
AtomicReference<Instant> lastFail = new AtomicReference<>();
|
||||
table.addEventHandler(KeyEvent.KEY_PRESSED, event -> {
|
||||
table.addEventHandler(KeyEvent.KEY_TYPED, event -> {
|
||||
updateTypedSelection(table, lastFail, event, false);
|
||||
});
|
||||
|
||||
|
@ -158,7 +158,7 @@ public final class BrowserFileListComp extends SimpleComp {
|
|||
}
|
||||
|
||||
private void updateTypedSelection(TableView<BrowserEntry> table, AtomicReference<Instant> lastType, KeyEvent event, boolean recursive) {
|
||||
var typed = event.getText();
|
||||
var typed = event.getCharacter();
|
||||
if (typed.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package io.xpipe.app.browser.session;
|
||||
|
||||
import atlantafx.base.controls.RingProgressIndicator;
|
||||
import atlantafx.base.theme.Styles;
|
||||
import io.xpipe.app.browser.BrowserWelcomeComp;
|
||||
import io.xpipe.app.comp.base.MultiContentComp;
|
||||
import io.xpipe.app.core.AppI18n;
|
||||
|
@ -12,8 +14,6 @@ import io.xpipe.app.fxcomps.util.PlatformThread;
|
|||
import io.xpipe.app.storage.DataStorage;
|
||||
import io.xpipe.app.util.BooleanScope;
|
||||
import io.xpipe.app.util.ContextMenuHelper;
|
||||
import io.xpipe.app.util.InputHelper;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.binding.Bindings;
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
|
@ -24,16 +24,10 @@ import javafx.collections.ListChangeListener;
|
|||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.input.DragEvent;
|
||||
import javafx.scene.input.KeyCode;
|
||||
import javafx.scene.input.KeyCodeCombination;
|
||||
import javafx.scene.input.KeyCombination;
|
||||
import javafx.scene.input.*;
|
||||
import javafx.scene.layout.Region;
|
||||
import javafx.scene.layout.StackPane;
|
||||
|
||||
import atlantafx.base.controls.RingProgressIndicator;
|
||||
import atlantafx.base.theme.Styles;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static atlantafx.base.theme.Styles.DENSE;
|
||||
|
@ -199,19 +193,19 @@ public class BrowserSessionTabsComp extends SimpleComp {
|
|||
}
|
||||
});
|
||||
|
||||
InputHelper.onInput(tabs, true, keyEvent -> {
|
||||
tabs.addEventFilter(KeyEvent.KEY_PRESSED, keyEvent -> {
|
||||
var current = tabs.getSelectionModel().getSelectedItem();
|
||||
if (current == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (keyEvent.getCode() == KeyCode.W && keyEvent.isShortcutDown()) {
|
||||
if (new KeyCodeCombination(KeyCode.W, KeyCombination.SHORTCUT_DOWN).match(keyEvent)) {
|
||||
tabs.getTabs().remove(current);
|
||||
keyEvent.consume();
|
||||
return;
|
||||
}
|
||||
|
||||
if (keyEvent.getCode() == KeyCode.W && keyEvent.isShortcutDown() && keyEvent.isShiftDown()) {
|
||||
if (new KeyCodeCombination(KeyCode.W, KeyCombination.SHORTCUT_DOWN, KeyCombination.SHIFT_DOWN).match(keyEvent)) {
|
||||
tabs.getTabs().clear();
|
||||
keyEvent.consume();
|
||||
}
|
||||
|
|
|
@ -11,29 +11,29 @@ import io.xpipe.app.prefs.AppPrefs;
|
|||
import io.xpipe.app.prefs.CloseBehaviourAlert;
|
||||
import io.xpipe.app.util.ThreadHelper;
|
||||
import io.xpipe.core.process.OsType;
|
||||
|
||||
import javafx.beans.property.BooleanProperty;
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
import javafx.geometry.Rectangle2D;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.input.KeyCode;
|
||||
import javafx.scene.input.KeyCodeCombination;
|
||||
import javafx.scene.input.KeyCombination;
|
||||
import javafx.scene.input.KeyEvent;
|
||||
import javafx.scene.layout.Region;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.stage.Screen;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Value;
|
||||
import lombok.extern.jackson.Jacksonized;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
public class AppMainWindow {
|
||||
|
||||
|
@ -169,8 +169,8 @@ public class AppMainWindow {
|
|||
e.consume();
|
||||
});
|
||||
|
||||
stage.addEventFilter(KeyEvent.KEY_PRESSED, event -> {
|
||||
if (event.getCode().equals(KeyCode.Q) && event.isShortcutDown()) {
|
||||
stage.addEventHandler(KeyEvent.KEY_PRESSED, event -> {
|
||||
if (new KeyCodeCombination(KeyCode.Q, KeyCombination.SHORTCUT_DOWN).match(event)) {
|
||||
stage.close();
|
||||
AppPrefs.get().closeBehaviour().getValue().run();
|
||||
event.consume();
|
||||
|
@ -274,7 +274,7 @@ public class AppMainWindow {
|
|||
|
||||
if (OsType.getLocal().equals(OsType.LINUX) || OsType.getLocal().equals(OsType.MACOS)) {
|
||||
stage.getScene().addEventFilter(KeyEvent.KEY_PRESSED, event -> {
|
||||
if (event.getCode().equals(KeyCode.W) && event.isShortcutDown()) {
|
||||
if (new KeyCodeCombination(KeyCode.W, KeyCombination.SHORTCUT_DOWN).match(event)) {
|
||||
AppPrefs.get().closeBehaviour().getValue().run();
|
||||
event.consume();
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@ import javafx.scene.Scene;
|
|||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.ButtonType;
|
||||
import javafx.scene.input.KeyCode;
|
||||
import javafx.scene.input.KeyCodeCombination;
|
||||
import javafx.scene.input.KeyCombination;
|
||||
import javafx.scene.input.KeyEvent;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.layout.Region;
|
||||
|
@ -143,7 +145,7 @@ public class AppWindowHelper {
|
|||
});
|
||||
AppWindowBounds.fixInvalidStagePosition(s);
|
||||
a.getDialogPane().getScene().addEventFilter(KeyEvent.KEY_PRESSED, event -> {
|
||||
if (event.getCode().equals(KeyCode.W) && event.isShortcutDown()) {
|
||||
if (new KeyCodeCombination(KeyCode.W, KeyCombination.SHORTCUT_DOWN).match(event)) {
|
||||
s.close();
|
||||
event.consume();
|
||||
return;
|
||||
|
@ -261,7 +263,7 @@ public class AppWindowHelper {
|
|||
});
|
||||
|
||||
scene.addEventFilter(KeyEvent.KEY_PRESSED, event -> {
|
||||
if (event.getCode().equals(KeyCode.W) && event.isShortcutDown()) {
|
||||
if (new KeyCodeCombination(KeyCode.W, KeyCombination.SHORTCUT_DOWN).match(event)) {
|
||||
stage.close();
|
||||
event.consume();
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ public class ErrorEvent {
|
|||
return EVENT_BASES.remove(t).description(msg);
|
||||
}
|
||||
|
||||
return builder().throwable(t).description(msg + (t.getMessage() != null ? "\n\n" + t.getMessage() : ""));
|
||||
return builder().throwable(t).description(msg + (t.getMessage() != null ? "\n\n" + t.getMessage().trim() : ""));
|
||||
}
|
||||
|
||||
public static ErrorEventBuilder fromMessage(String msg) {
|
||||
|
|
|
@ -2,10 +2,7 @@ package io.xpipe.app.util;
|
|||
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.event.EventTarget;
|
||||
import javafx.scene.input.KeyCode;
|
||||
import javafx.scene.input.KeyCombination;
|
||||
import javafx.scene.input.KeyEvent;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
import javafx.scene.input.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
@ -27,11 +24,7 @@ public class InputHelper {
|
|||
|
||||
public static void onExactKeyCode(EventTarget target, KeyCode code, boolean filter, Consumer<KeyEvent> r) {
|
||||
EventHandler<KeyEvent> keyEventEventHandler = event -> {
|
||||
if (event.isAltDown() || event.isShiftDown() || event.isShortcutDown()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (code == event.getCode()) {
|
||||
if (new KeyCodeCombination(code).match(event)) {
|
||||
r.accept(event);
|
||||
}
|
||||
};
|
||||
|
@ -42,20 +35,9 @@ public class InputHelper {
|
|||
}
|
||||
}
|
||||
|
||||
public static void onInput(EventTarget target, boolean filter, Consumer<KeyEvent> r) {
|
||||
EventHandler<KeyEvent> keyEventEventHandler = event -> {
|
||||
r.accept(event);
|
||||
};
|
||||
if (filter) {
|
||||
target.addEventFilter(KeyEvent.KEY_PRESSED, keyEventEventHandler);
|
||||
} else {
|
||||
target.addEventHandler(KeyEvent.KEY_PRESSED, keyEventEventHandler);
|
||||
}
|
||||
}
|
||||
|
||||
public static void onLeft(EventTarget target, boolean filter, Consumer<KeyEvent> r) {
|
||||
EventHandler<KeyEvent> e = event -> {
|
||||
if (event.getCode() == KeyCode.LEFT || event.getCode() == KeyCode.NUMPAD4) {
|
||||
if (new KeyCodeCombination(KeyCode.LEFT).match(event) || new KeyCodeCombination(KeyCode.NUMPAD4).match(event)) {
|
||||
r.accept(event);
|
||||
}
|
||||
};
|
||||
|
@ -68,7 +50,7 @@ public class InputHelper {
|
|||
|
||||
public static void onRight(EventTarget target, boolean filter, Consumer<KeyEvent> r) {
|
||||
EventHandler<KeyEvent> e = event -> {
|
||||
if (event.getCode() == KeyCode.RIGHT || event.getCode() == KeyCode.NUMPAD6) {
|
||||
if (new KeyCodeCombination(KeyCode.RIGHT).match(event) || new KeyCodeCombination(KeyCode.NUMPAD6).match(event)) {
|
||||
r.accept(event);
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue