Do not trigger current-item-changed on StandardListView if current-item is set on the same value (#5958)

This commit is contained in:
FloVanGH 2024-08-27 07:22:18 +00:00 committed by GitHub
parent 1d434ad242
commit 7a0c3dcc50
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 11 additions and 4 deletions

View file

@ -8,6 +8,7 @@ All notable changes to this project are documented in this file.
### Widgets
- Fixed `TextEdit` not invoking `edited` callbacks (#5848).
- Do not trigger `current-item-changed` on `StandardListView` if `current-item` is set on the same value.
## [1.7.2] - 2024-08-14

View file

@ -13,10 +13,10 @@ component StandardListViewBase inherits ListView {
in-out property <int> current-item: -1;
callback current-item-changed(/* current-item */ int);
callback item-pointer-event( /* item-index */ int, /* event */ PointerEvent, /* absolute mouse position */ Point);
callback item-pointer-event(/* item-index */ int, /* event */ PointerEvent, /* absolute mouse position */ Point);
public function set-current-item(index: int) {
if (index < 0 || index >= model.length) {
if index < 0 || index >= model.length || index == root.current-item {
return;
}

View file

@ -7,7 +7,7 @@ TestCase := Rectangle {
callback set-current-item(int);
out property <int> count: list.model.length;
out property <int> callback-current-item: -1;
in-out property <int> callback-current-item: -1;
in-out property<[StandardListViewItem]> model: [
{ text: "Item 1" },
@ -41,5 +41,11 @@ assert_eq!(instance.get_callback_current_item(), -1);
instance.invoke_set_current_item(1);
assert_eq!(instance.get_callback_current_item(), 1);
assert_eq!(instance.get_current_item(), 1);
instance.set_callback_current_item(-1);
instance.invoke_set_current_item(1);
assert_eq!(instance.get_callback_current_item(), -1);
assert_eq!(instance.get_current_item(), 1);
```
*/
*/