-
Notifications
You must be signed in to change notification settings - Fork 818
使用 LineSelectButton 代替 JFXComboxBox #5337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
|
实测换行问题还在。 另外,字体选择框有计划实现吗? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 24 out of 24 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (1)
HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/ComponentList.java:106
- getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
public ObservableList<Node> getContent() {
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| .line-select-button .menu-container .title { | ||
| -fx-font-size: 13px; | ||
| -fx-text-fill: -monet-on-surface; | ||
| } | ||
|
|
||
| .line-select-button .menu-container:selected .title { | ||
| -fx-text-fill: -monet-primary; | ||
| } | ||
|
|
||
| .line-select-button .popup-menu .subtitle { |
Copilot
AI
Jan 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这些样式选择器以 .line-select-button ... 作为祖先限定,但 LineSelectButton 的下拉菜单是通过 JFXPopup 在独立的 PopupWindow/Scene 中显示的,因此 .menu-container / .popup-menu 节点通常不会是 .line-select-button 的后代,导致这些规则不生效。建议改为基于 .popup-menu(或给该 PopupMenu 额外加一个专用 style class 再在 CSS 中选择)来定义标题/选中态/副标题样式。
| .line-select-button .menu-container .title { | |
| -fx-font-size: 13px; | |
| -fx-text-fill: -monet-on-surface; | |
| } | |
| .line-select-button .menu-container:selected .title { | |
| -fx-text-fill: -monet-primary; | |
| } | |
| .line-select-button .popup-menu .subtitle { | |
| .popup-menu .menu-container .title { | |
| -fx-font-size: 13px; | |
| -fx-text-fill: -monet-on-surface; | |
| } | |
| .popup-menu .menu-container:selected .title { | |
| -fx-text-fill: -monet-primary; | |
| } | |
| .popup-menu .subtitle { |
HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/LineSelectButton.java
Outdated
Show resolved
Hide resolved
HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/LineSelectButton.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 25 out of 25 changed files in this pull request and generated 6 comments.
Comments suppressed due to low confidence (1)
HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/ComponentList.java:106
- getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
getContent exposes the internal representation stored in field content. The value may be modified after this call to getContent.
public ObservableList<Node> getContent() {
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| private final ListProperty<T> items = new SimpleListProperty<>(this, "items", FXCollections.emptyObservableList()); | ||
|
|
||
| public ListProperty<T> itemsProperty() { | ||
| return items; | ||
| } |
Copilot
AI
Jan 29, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
items 的默认值使用了 FXCollections.emptyObservableList()(不可修改)。如果外部代码调用 getItems().add(...)/getItems().setAll(...) 会直接抛 UnsupportedOperationException。作为可复用控件的公开 API,建议默认使用可变的 FXCollections.observableArrayList()(或在 getItems() 返回前确保可变)。
| popup.hide(); | ||
| }); | ||
|
|
||
| FXUtils.onChangeAndOperate(valueProperty(), |
Copilot
AI
Jan 29, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里为每个菜单项都用 FXUtils.onChangeAndOperate(valueProperty(), ...) 给 LineSelectButton.valueProperty() 添加了一个强引用监听器。菜单项节点被移除/重建时(items 变化、页面销毁)这些监听器不会自动移除,可能导致节点无法被 GC(内存泄漏)并造成不必要的更新开销。建议改用弱监听(如 FXUtils.onWeakChangeAndOperate/WeakChangeListener),或在菜单项节点生命周期结束时显式移除监听器。
| FXUtils.onChangeAndOperate(valueProperty(), | |
| FXUtils.onWeakChangeAndOperate(valueProperty(), |
HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/LineSelectButton.java
Show resolved
Hide resolved
Co-authored-by: Copilot <[email protected]>
本 PR 实现了一个新控件
LineSelectButton用于替代JFXComboxBox: