feat: 修改重命名时tab tilte样式,并获取焦点
This commit is contained in:
parent
895fae18f4
commit
ba5172d78e
@ -56,8 +56,7 @@ public class RenameFile implements EventHandler<ActionEvent> {
|
|||||||
// 如果当前不是关联文件则重命名标签页
|
// 如果当前不是关联文件则重命名标签页
|
||||||
else {
|
else {
|
||||||
TextField textField = new TextField(jnotepadtab.getText());
|
TextField textField = new TextField(jnotepadtab.getText());
|
||||||
// 设置文本框尺寸
|
textField.getStyleClass().add("tab-title-editable");
|
||||||
textField.setPrefSize(120, 12);
|
|
||||||
// 清空标签页名称
|
// 清空标签页名称
|
||||||
jnotepadtab.setText("");
|
jnotepadtab.setText("");
|
||||||
// 监听 Enter 键,完成编辑
|
// 监听 Enter 键,完成编辑
|
||||||
@ -83,6 +82,9 @@ public class RenameFile implements EventHandler<ActionEvent> {
|
|||||||
jnotepadtab.setClosable(false);
|
jnotepadtab.setClosable(false);
|
||||||
// 设置 TextField 作为标签页的图形
|
// 设置 TextField 作为标签页的图形
|
||||||
jnotepadtab.setGraphic(textField);
|
jnotepadtab.setGraphic(textField);
|
||||||
|
// 默认获取焦点并选中所有文字
|
||||||
|
textField.requestFocus();
|
||||||
|
textField.selectAll();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,4 +24,13 @@
|
|||||||
.main-text-area {
|
.main-text-area {
|
||||||
-fx-border-color: white;
|
-fx-border-color: white;
|
||||||
-fx-background-color: white;
|
-fx-background-color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* tab修改标签样式 */
|
||||||
|
.tab-title-editable {
|
||||||
|
-fx-fx-border-width: 0;
|
||||||
|
-fx-max-width: 80px;
|
||||||
|
-fx-max-height: 30px;
|
||||||
|
-fx-font-size: 14px;
|
||||||
|
-fx-padding: 2px 2px 2px 2px;
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user