Button.holdtime ??
TurnipTruck
Junior Member
Greetings,
Has someone some experience with the BUTTON.HOLDTIME data object?
What part of a button event could it be used in?
In the HOLD: it would seem that it could be used to increment a variable as the button is held??
Thanks
Has someone some experience with the BUTTON.HOLDTIME data object?
What part of a button event could it be used in?
In the HOLD: it would seem that it could be used to increment a variable as the button is held??
HOLD:
{
nVARIABLE=BUTTON.HOLDTIME
}
Seems awful processor intensive.RELEASE:
{
nVARIABLE=BUTTON.HOLDTIME
}
Seems like not the right place to put it.Thanks
Comments
-
mpullin wrote in another thread:
To be fair, I come from a computer programming background and NL timelines don't represent any classical data structure so that could have something to do with why I can't stand them.
Your changed rate of holding & repeating can be accomplished via HOLDTIME btw.
Code:
BUTTON_EVENT[arrTP,butBUTTON]{
PUSH: PULSE[dvDEVICE,1]
HOLD[5,REPEAT]: if(BUTTON.HOLDTIME % 10 == 0 || BUTTON.HOLDTIME > 50) PULSE[dvDEVICE,1]
}This code will pulse every second until 5 seconds have passed, then it will pulse twice a second.
This is a very simple yet efficient way to do variable hold and repeats. Just like an alarm clock or radio button where you hold the button down and the time advances slowly but keep holding, say after 5 seconds it starts to advance faster.
I originally did this variable hold-n-repeat via a time_line cuz I didn't know button.holdtime existed, although I'm sure I glanced over a million times but matt posted this just a few weeks ago and in one line it does what 10 lines or more did via the time_line.
And I thought I was clever when I created the time_line version. Oh well, live and learn! -
RELEASE: { nVARIABLE=BUTTON.HOLDTIME }
Well, the holdtime will always be 0 in the release - 'cause if you release the button, it's not longer hold
One more solution if you need to do some action if button was hold long or short:DEFINE_VARIABLE INTEGER nFlag DEFINE_EVENT BUTTON_EVENT[dvPanel,1] { HOLD[50]: { nFlag = TRUE // do action if button was hold for 5 seconds } RELEASE: { IF(nFlag) { // button was hold less than 5 seconds } nFlag = FALSE } }I'm missing a EVENT_VAR - a variable which is usable within the whole event (similar to a LOCAL_VAR / STACK_VAR within i.e. the PUSH section)
Categories
- All Categories
- 2.5K AMX General Discussion
- 922 AMX Technical Discussion
- 514 AMX Hardware
- 502 AMX Control Products
- 3 AMX Video Distribution Products
- 9 AMX Networked AV (SVSI) Products
- AMX Workspace & Collaboration Products
- 3.4K AMX Software
- 151 AMX Resource Management Suite Software
- 386 AMX Design Tools
- 2.4K NetLinx Studio
- 135 Duet/Cafe Duet
- 248 NetLinx Modules & Duet Modules
- 57 AMX RPM Forum
- 228 MODPEDIA - The Public Repository of Modules for Everyone
- 943 AMX Specialty Forums
- 2.6K AMXForums Archive
- 2.6K AMXForums Archive Threads
- 1.5K AMX Hardware
- 432 AMX Applications and Solutions
- 249 Residential Forum
- 182 Tips and Tricks
- 146 AMX Website/Forums
