How to detect when a button is pressed/released/toggled, not just clicked #9105
-
Hello! Love Slint, this project is awesome. When working with a basic My use case is controlling a motor. When I press the button, I want the motor to be on for as long as the button is held. When the button is released, I want to stop the motor. I just don't know how to separately detect press and release events. Additionally, is there an easy way to detect when a button has been toggled if it is Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
I can't say for certain, because I've never tried, I think you would need to create your own custom button to do that. Here is a quick thrown together example showing a rough idea of handling the down and up events on a touch area for a custom "button". It's not exactly what you want, but hopefully will lead you in the right direction. In regards to reacting to if the button has been toggled, haven't tested this, but perhaps add in a changed callback for the buttons state?: https://slint.dev/blog/property-changed-callback |
Beta Was this translation helpful? Give feedback.
I can't say for certain, because I've never tried, I think you would need to create your own custom button to do that.
Here is a quick thrown together example showing a rough idea of handling the down and up events on a touch area for a custom "button". It's not exactly what you want, but hopefully will lead you in the right direction.
In regards to reacting to if the button has been toggled, haven't tested this, but perhaps add in a changed callback for the buttons state?: https://slint.dev/blog/property-changed-callback