Skip to content

Conversation

@Glavo
Copy link
Member

@Glavo Glavo commented Jan 27, 2026

本 PR 实现了一个新控件 LineSelectButton 用于替代 JFXComboxBox

图片 图片

@Glavo Glavo marked this pull request as draft January 27, 2026 14:32
@3gf8jv4dv

This comment was marked as resolved.

@3gf8jv4dv
Copy link
Contributor

实测换行问题还在。

另外,字体选择框有计划实现吗?

Copy link
Contributor

Copilot AI left a 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

    public ObservableList<Node> getContent() {

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 1868 to 1877
.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 {
Copy link

Copilot AI Jan 28, 2026

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 中选择)来定义标题/选中态/副标题样式。

Suggested change
.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 {

Copilot uses AI. Check for mistakes.
@Glavo Glavo changed the title 新增控件 LineSelectButton 使用 LineSelectButton 代替 JFXComboxBox Jan 28, 2026
Copy link
Contributor

Copilot AI left a 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

    public ObservableList<Node> getContent() {

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +204 to +208
private final ListProperty<T> items = new SimpleListProperty<>(this, "items", FXCollections.emptyObservableList());

public ListProperty<T> itemsProperty() {
return items;
}
Copy link

Copilot AI Jan 29, 2026

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() 返回前确保可变)。

Copilot uses AI. Check for mistakes.
popup.hide();
});

FXUtils.onChangeAndOperate(valueProperty(),
Copy link

Copilot AI Jan 29, 2026

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),或在菜单项节点生命周期结束时显式移除监听器。

Suggested change
FXUtils.onChangeAndOperate(valueProperty(),
FXUtils.onWeakChangeAndOperate(valueProperty(),

Copilot uses AI. Check for mistakes.
@Glavo Glavo merged commit e323185 into HMCL-dev:main Jan 29, 2026
2 checks passed
@Glavo Glavo deleted the choose-item branch January 29, 2026 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants