mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-21 23:20:23 +00:00
Finish new item action on enter
This commit is contained in:
parent
89776bb6da
commit
7c6906d86e
3 changed files with 24 additions and 8 deletions
|
@ -48,7 +48,8 @@ public class ErrorOverlayComp extends SimpleComp {
|
|||
return new StackPane(graphic);
|
||||
}),
|
||||
null,
|
||||
() -> {}));
|
||||
() -> {},
|
||||
false));
|
||||
});
|
||||
});
|
||||
content.addListener((observable, oldValue, newValue) -> {
|
||||
|
|
|
@ -14,6 +14,8 @@ import javafx.geometry.Insets;
|
|||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ButtonBar;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.input.KeyCode;
|
||||
import javafx.scene.input.KeyEvent;
|
||||
import javafx.scene.layout.Region;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.scene.layout.VBox;
|
||||
|
@ -81,6 +83,7 @@ public class ModalOverlayComp extends SimpleComp {
|
|||
finishButton.setOnAction(event -> {
|
||||
newValue.onFinish.run();
|
||||
overlayContent.setValue(null);
|
||||
event.consume();
|
||||
});
|
||||
|
||||
var buttonBar = new ButtonBar();
|
||||
|
@ -105,6 +108,16 @@ public class ModalOverlayComp extends SimpleComp {
|
|||
});
|
||||
modal.show(modalBox);
|
||||
|
||||
if (newValue.finishOnEnter) {
|
||||
modalBox.addEventFilter(KeyEvent.KEY_PRESSED, event -> {
|
||||
if (event.getCode() == KeyCode.ENTER) {
|
||||
newValue.onFinish.run();
|
||||
overlayContent.setValue(null);
|
||||
event.consume();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Wait 2 pulses before focus so that the scene can be assigned to r
|
||||
Platform.runLater(() -> {
|
||||
Platform.runLater(() -> {
|
||||
|
@ -124,5 +137,6 @@ public class ModalOverlayComp extends SimpleComp {
|
|||
Comp<?> graphic;
|
||||
String finishKey;
|
||||
Runnable onFinish;
|
||||
boolean finishOnEnter;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,12 +11,10 @@ import io.xpipe.app.core.AppI18n;
|
|||
import io.xpipe.app.fxcomps.Comp;
|
||||
import io.xpipe.app.util.OptionsBuilder;
|
||||
import io.xpipe.core.process.OsType;
|
||||
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.TextField;
|
||||
|
||||
import org.kordamp.ikonli.javafx.FontIcon;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -66,12 +64,13 @@ public class NewItemAction implements BrowserAction, BranchAction {
|
|||
var creationName = new TextField();
|
||||
creationName.textProperty().bindBidirectional(name);
|
||||
return creationName;
|
||||
}),
|
||||
}).prefWidth(350),
|
||||
null,
|
||||
"finish",
|
||||
() -> {
|
||||
model.createFileAsync(name.getValue());
|
||||
}));
|
||||
},
|
||||
true));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -95,12 +94,13 @@ public class NewItemAction implements BrowserAction, BranchAction {
|
|||
var creationName = new TextField();
|
||||
creationName.textProperty().bindBidirectional(name);
|
||||
return creationName;
|
||||
}),
|
||||
}).prefWidth(350),
|
||||
null,
|
||||
"finish",
|
||||
() -> {
|
||||
model.createDirectoryAsync(name.getValue());
|
||||
}));
|
||||
},
|
||||
true));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -132,7 +132,8 @@ public class NewItemAction implements BrowserAction, BranchAction {
|
|||
"finish",
|
||||
() -> {
|
||||
model.createLinkAsync(linkName.getValue(), target.getValue());
|
||||
}));
|
||||
},
|
||||
true));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue