material: SegmentedButton: Add index-changed callback. (https://github.com/slint-ui/material-components/issues/149)

Imported from 67d5871e56
This commit is contained in:
Nigel Breslaw 2025-09-04 17:16:59 +03:00 committed by Olivier Goffart
parent 4a9192883a
commit eb105c8593
2 changed files with 8 additions and 0 deletions

View file

@ -39,6 +39,11 @@ The index of the currently selected item.
An array of segmented items, each containing an icon and text.
</SlintProperty>
## Callbacks
### index-changed(index: int)
Invoked when the current-index changes.
## Functions
### select(index: int)

View file

@ -63,6 +63,8 @@ export component SegmentedButton {
in property <[SegmentedItem]> model;
in_out property <int> current_index;
callback index_changed(index: int);
min_width: max(2 * MaterialStyleMetrics.size_40, layout.min_width);
min_height: max(MaterialStyleMetrics.size_40, layout.min_height);
@ -96,5 +98,6 @@ export component SegmentedButton {
}
root.current_index = index;
root.index_changed(index);
}
}