fix: select logs outside the screen was not deselected correctly#5955
fix: select logs outside the screen was not deselected correctly#5955pynickle wants to merge 3 commits intoHMCL-dev:mainfrom
Conversation
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors the log selection mechanism by removing the manual selection state from the Log model and LogWindowSkin, utilizing the built-in JavaFX SelectionModel instead. Feedback highlights that this change might result in the loss of selection persistence during log filtering and suggests moving the selection mode configuration to the control's constructor. Furthermore, it is recommended to verify if the selection is empty before executing the copy logic to optimize performance and UI behavior.
|
|
||
| private final String log; | ||
| private Log4jLevel level; | ||
| private boolean selected = false; |
There was a problem hiding this comment.
Removing the selected field from the Log model means that selection state is no longer persistent when logs are filtered. In the previous implementation, selection was stored in the data model, allowing it to be preserved even if an item was temporarily hidden by a filter (e.g., toggling log levels). With this change, selection is tied strictly to the ListView's current items and will be lost whenever shakeLogs() (which calls setAll()) is triggered. If persistent selection across filtering is a requirement, consider maintaining the selected state in the Log class and synchronizing it with the SelectionModel.
There was a problem hiding this comment.
考虑过这一点 但是感觉这点行为差异并不是很要紧的事情)应该不会有人在多选之后 filter 还要求保留之前的多选吧
|
|
||
| { | ||
| ListView<Log> listView = control.listView; | ||
| listView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); |
There was a problem hiding this comment.
While setting the selection mode in the skin works, it is generally better practice to configure the control's properties (like the selection model's mode) within the control's constructor (LogWindowImpl) rather than in the skin. This ensures the control is correctly initialized regardless of the skin being used.
Fix #5884
使用 JavaFX 原生的 SelectionModel 代替自建 selected