Comments (1)
This patch fixes it for me (the Qt slider already implements this):
diff --git a/internal/compiler/widgets/common/slider-base.slint b/internal/compiler/widgets/common/slider-base.slint
index 2451ecf08..cbdcb6952 100644
--- a/internal/compiler/widgets/common/slider-base.slint
+++ b/internal/compiler/widgets/common/slider-base.slint
@@ -32,16 +32,15 @@ export component SliderBase {
width: 100%;
height: 100%;
- clicked => {
- released(root.value);
- }
-
pointer-event(event) => {
if (event.button != PointerEventButton.left) {
return;
}
if (event.kind == PointerEventKind.up) {
+ if (root.handle-pressed) {
+ released(root.value);
+ }
root.handle-pressed = false;
return;
}
but I'm having trouble making at test for it.
I tried this, but somehow the pointer event isn't triggered:
diff --git a/tests/cases/widgets/slider_basic.slint b/tests/cases/widgets/slider_basic.slint
index e656ca84e..d91a6bd0c 100644
--- a/tests/cases/widgets/slider_basic.slint
+++ b/tests/cases/widgets/slider_basic.slint
@@ -10,12 +10,14 @@ export component TestCase inherits Window {
minimum: 0;
maximum: 100;
value: 10;
+ accessible-label: "testslider";
}
forward-focus: slider;
out property <bool> slider-focused <=> slider.has_focus;
callback released <=> slider.released;
callback changed <=> slider.changed;
+ in property value <=> slider.value;
}
/*
@@ -60,6 +62,28 @@ slint_testing::send_keyboard_char(&instance, 'a', false);
assert_eq!(edits.borrow().clone(), vec![14f32]);
assert_eq!(changes.borrow().clone(), vec![11f32, 12f32, 13f32, 14f32]);
+edits.borrow_mut().clear();
+
+// Reset to center
+instance.set_value(50.);
+
+let slider = slint_testing::ElementHandle::find_by_accessible_label(&instance, "testslider").next().unwrap();
+
+// Press center and then drag outside
+let mut position = slider.absolute_position();
+position.x += slider.size().width / 2.;
+position.y += slider.size().height / 2.;
+let button = slint::platform::PointerEventButton::Left;
+instance.window().dispatch_event(slint::platform::WindowEvent::PointerMoved { position });
+instance.window().dispatch_event(slint::platform::WindowEvent::PointerPressed { position, button });
+slint_testing::mock_elapsed_time(50);
+for x in (position.x as usize..200).step_by(10) {
+ position.x = x as _;
+ instance.window().dispatch_event(slint::platform::WindowEvent::PointerMoved { position });
+}
+instance.window().dispatch_event(slint::platform::WindowEvent::PointerReleased { position, button });
+assert_eq!(edits.borrow().clone(), vec![100f32]);
+
@ogoffart @FloVanGH do you have any idea what I'm doing wrong?
from slint.
Related Issues (20)
- Compiler panic compiling `init` callback from a component inlined into a repeater HOT 1
- Include LTS Version as slintpad dependency
- I created a TextEdit that automatically fills in a string of keyboard characters when switching from the desktop window. Can anyone tell me why? I am very distressed HOT 4
- hide() directly closes the program HOT 3
- Introduce undefined values for properties and struct fields HOT 3
- The emoji in TextInput is gray HOT 3
- TextInput symbol output issue HOT 2
- Slint has been in contact for a week, summarizing the issues HOT 1
- Why is the result of slint viewer different from vscode, and the rendering result of rust the same as that of slint viewer?
- Text blurry with femtovg renderer HOT 1
- Feature Request: Top Level Generic Widget HOT 4
- Dependencies within slint crates are out of sync with each other. HOT 4
- Winit-skia-vulkan crash HOT 3
- Moving a named element produces a syntax error HOT 3
- Partial override fields of a struct HOT 2
- VSCode language server panic in dynamic_item_tree.rs HOT 3
- Screen doesn't update until manually changing the window to fullscreen in Windows 10 HOT 1
- Property change is propagated too far (even when the value remains the same) HOT 2
- Updating the `model` of a `ComboBox` does not change the currently displayed text HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from slint.