![]() |
onClicked to repeat when held
Hi all,
I've struggled to find any hints on how to do this, so I ask here. I have made a remote control app to control my LED RGBW lighting strips. The remote app has 40 buttons. 4 of these 40 buttons could do with being repeatable, so I can either single click or hold for multiple clicks. NOTE: I'm not actually using buttons, but instead, I'm using rectangles with a mouse area. I would then use this for say, controlling brightness of my RGBW strip, just holding "Bright +" will go all the way and vice-versa. How to achieve this please? Thanks, |
Re: onClicked to repeat when held
Buttons have a "down" property. IIRC you can set a onDownChanged event handler. If down == true, set an interval using javascript's setInterval, in which you increase/decrease the brightness every x milliseconds. Clear the interval when down gets false.
The documentation refers to MouseArea, which give you the "pressed" property, and thus onPressed and onReleased. I'm not sure whether Button inherits these tho. Incidentally, Qt 5.9 introduced "pressAndHold"... |
Re: onClicked to repeat when held
Thanks for replying, but I've neglected a key piece of information: I'm not using buttons but rectangles with a mouse area.
I have played with onPressed/onReleased, but to no avail. I am also aware of press and hold but couldn't find a working example or even something I could adapt, it's not urgent, but I'd like to solve it. @Fuzzillogic - I've updated my original question to reflect your comments, thanks. |
Re: onClicked to repeat when held
Code:
Rectangle { edit: it's QtQuick, so declarative all the things! I like this more: Code:
Timer { |
Re: onClicked to repeat when held
Okay, thanks Fuzzi for your input, with a few glasses of wine and a couple of neatly rolled magical smoking sticks, I have arrived at a place where the code works, it ain't pretty, but hey, for now, this is for personal use :)
Right, taking some of your advice and code, I came up with this (this is a snippet of a very long single page); This works, although it's bulky, untidy and repetitive, but my UI now has 40 fully functioning buttons (rectangles) Code:
// First row of 10, consists of rectangle, mouse and label I also note that there is a github page for RGB IR WIFI control, but it meant uploading new unknown code to my NodeMCU and for now, I'm happy with the way my set up works, albeit, as previously stated; bulky, untidy....in dire need or refinement, but for who?, it works! :D Thanks for your input Fuzzillogic, much appreciated. Regards, |
All times are GMT. The time now is 03:47. |
vBulletin® Version 3.8.8