Fix ScrollView scrollbar actions not triggering scrolled callback

Fixes #8170
This commit is contained in:
Bryce Happel Walton 2025-04-28 04:56:30 -04:00 committed by GitHub
parent e357222e59
commit 769f85584d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 28 additions and 0 deletions

View file

@ -13,6 +13,8 @@ export component ScrollBar {
in-out property <length> value;
in property <ScrollBarPolicy> policy: ScrollBarPolicy.as-needed;
callback scrolled();
private property <length> track-size: root.horizontal ? root.width - 2 * root.offset : root.height - 2 * offset;
private property <length> step-size: 10px;
private property <length> offset: 2px;
@ -63,6 +65,7 @@ export component ScrollBar {
root.horizontal ? (touch-area.mouse-x - touch-area.pressed-x) * (root.maximum / (root.track-size - thumb.width))
: (touch-area.mouse-y - touch-area.pressed-y) * (root.maximum / (root.track-size - thumb.height))
)));
root.scrolled();
}
}
@ -120,6 +123,8 @@ export component ScrollView {
horizontal: false;
maximum: flickable.viewport-height - flickable.height;
page-size: flickable.height;
scrolled => {root.scrolled()}
}
horizontal-bar := ScrollBar {
@ -131,5 +136,7 @@ export component ScrollView {
horizontal: true;
maximum: flickable.viewport-width - flickable.width;
page-size: flickable.width;
scrolled => {root.scrolled()}
}
}

View file

@ -12,6 +12,8 @@ export component ScrollBar inherits Rectangle {
in-out property <length> value;
in property <ScrollBarPolicy> policy: ScrollBarPolicy.as-needed;
callback scrolled();
property <length> track-size: root.horizontal ? root.width - 2 * root.offset : root.height - 2 * offset;
property <length> step-size: 10px;
property <length> offset: 2px;
@ -71,6 +73,7 @@ export component ScrollBar inherits Rectangle {
root.horizontal ? (touch-area.mouse-x - touch-area.pressed-x) * (root.maximum / (root.track-size - thumb.width))
: (touch-area.mouse-y - touch-area.pressed-y) * (root.maximum / (root.track-size - thumb.height))
)));
root.scrolled();
}
}
@ -130,6 +133,8 @@ export component ScrollView {
horizontal: false;
maximum: flickable.viewport-height - flickable.height;
page-size: flickable.height;
scrolled => {root.scrolled()}
}
horizontal-bar := ScrollBar {
@ -141,5 +146,7 @@ export component ScrollView {
horizontal: true;
maximum: flickable.viewport-width - flickable.width;
page-size: flickable.width;
scrolled => {root.scrolled()}
}
}

View file

@ -42,6 +42,8 @@ component ScrollBar inherits Rectangle {
in property <ScrollBarPolicy> policy: ScrollBarPolicy.as-needed;
in property <bool> enabled;
callback scrolled();
property <length> offset: 16px;
property <length> size: 2px;
property <length> track-size: root.horizontal ? root.width - 2 * root.offset : root.height - 2 * offset;
@ -92,6 +94,7 @@ component ScrollBar inherits Rectangle {
root.horizontal ? (touch-area.mouse-x - touch-area.pressed-x) * (root.maximum / (root.track-size - thumb.width))
: (touch-area.mouse-y - touch-area.pressed-y) * (root.maximum / (root.track-size - thumb.height))
)));
root.scrolled();
}
}
@ -174,6 +177,8 @@ export component ScrollView {
horizontal: false;
maximum: flickable.viewport-height - flickable.height;
page-size: flickable.height;
scrolled => {root.scrolled()}
}
horizontal-bar := ScrollBar {
@ -185,5 +190,7 @@ export component ScrollView {
horizontal: true;
maximum: flickable.viewport-width - flickable.width;
page-size: flickable.width;
scrolled => {root.scrolled()}
}
}

View file

@ -13,6 +13,8 @@ component ScrollBar inherits Rectangle {
in-out property <bool> enabled <=> touch-area.enabled;
in property <ScrollBarPolicy> policy: ScrollBarPolicy.as-needed;
callback scrolled();
states [
disabled when !touch-area.enabled : {
background.border-color: MaterialPalette.control-foreground;
@ -73,6 +75,7 @@ component ScrollBar inherits Rectangle {
root.horizontal ? (touch-area.mouse-x - touch-area.pressed-x) * (root.maximum / (root.width - handle.width))
: (touch-area.mouse-y - touch-area.pressed-y) * (root.maximum / (root.height - handle.height))
)));
root.scrolled();
}
}
@ -131,6 +134,8 @@ export component ScrollView {
maximum: flickable.viewport-height - flickable.height;
page-size: flickable.height;
enabled: root.enabled;
scrolled => {root.scrolled()}
}
horizontal-bar := ScrollBar {
@ -142,5 +147,7 @@ export component ScrollView {
maximum: flickable.viewport-width - flickable.width;
page-size: flickable.width;
enabled: root.enabled;
scrolled => {root.scrolled()}
}
}