Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Mouse hold

Flivelwitz Alsop
Registered User
Join date: 26 Mar 2008
Posts: 6
07-20-2009 04:29
Is there a command to allow me to hold the cursor over on a prim (like a HUD button), and click and hold the mouse button which will make an event loop over and over (like a held note, a color change, etc), until I release the mouse button? Thanks!
Lance Corrimal
I don't do stupid.
Join date: 9 Jun 2006
Posts: 877
07-20-2009 04:59
i dont know if this approach is feasible:


catch the touch_start event to start your loop
catch the touch_end event to end it.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
07-20-2009 05:09
From: Flivelwitz Alsop
Is there a command to allow me to hold the cursor over on a prim (like a HUD button), and click and hold the mouse button which will make an event loop over and over (like a held note, a color change, etc), until I release the mouse button? Thanks!

yup....
insead of using touch_start, or touch_end, just use touch..... but you should be aware that it's going to almost always double trigger, so actually it's best to use all thre (and you may need to add a sleep in you touch...

eg
CODE

integer vBooIsHeld;

default{
touch_start( integer vInt ){
vBooIsHeld = TRUE;
}

touch( integer vInt ){
if (vBooIsHeld){
llOwnerSay( "Triggering in ~1second loops" );
llSleep( 1.0 );
}
}

touch_end( integer vInt ){
vBooIsHeld = FALSE;
}
}
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Tali Rosca
Plywood Whisperer
Join date: 6 Feb 2007
Posts: 767
07-20-2009 05:26
You can start an llSetTimerEvent on touch_start and clear it again on touch_end. Depending on just what you need, that may be the best way to go.

One problem with using the touch even is that it fires very quickly, so the events can quickly stack up in the queue if you're not careful about what you're doing. -You can fiddle with llMinEventDelay, but since that messes with the whole script, you may not want that.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
07-20-2009 06:13
From: Tali Rosca
You can start an llSetTimerEvent on touch_start and clear it again on touch_end. Depending on just what you need, that may be the best way to go.

One problem with using the touch even is that it fires very quickly, so the events can quickly stack up in the queue if you're not careful about what you're doing. -You can fiddle with llMinEventDelay, but since that messes with the whole script, you may not want that.

no av will be registered more than once in the same touch event, so the stacking isn't an issue for a hud (since only one av could be touching)

the timer version may take a little more finesse as it's going to trigger the first time AFTER the timer delay (you could use a custom function, call it before you set the timer, and call it again when the timer fires). the other problem there is that the timer may queue up before it gets turned off, causing an extra trigger (unless you also test a variable before running the timer code). code size-wise the triple touch event tends to work out as a smaller equivalent, because of the extra overhead involved in the other method.

ETA:
both methods would suffer possible premature shutoffs with mutiple touching avs (as the first av lets go, the test or timer is shut off) but a combination method, where the timer shuts itself off, but the "touch" event continually sets a variable to true could work in that scenario.
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Tali Rosca
Plywood Whisperer
Join date: 6 Feb 2007
Posts: 767
07-20-2009 06:43
From: Void Singer
no av will be registered more than once in the same touch event, so the stacking isn't an issue for a hud (since only one av could be touching)

...Unless you're sending commands to other scripts to perform the actual action, in which case you can easily send them faster than the receiver can process them if it is doing anything with a delay. I just wanted to warn that touch can be one of the most aggressive events, but it may not be an issue, depending on use.
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
07-20-2009 06:49
I use a timer on touch_start and shut off on touch_end, with the hold action taking place in the timer event.
_____________________
Argent Stonecutter - http://globalcausalityviolation.blogspot.com/

"And now I'm going to show you something really cool."

Skyhook Station - http://xrl.us/skyhook23
Coonspiracy Store - http://xrl.us/coonstore
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
07-20-2009 06:57
From: Tali Rosca
...Unless you're sending commands to other scripts to perform the actual action, in which case you can easily send them faster than the receiver can process them if it is doing anything with a delay. I just wanted to warn that touch can be one of the most aggressive events, but it may not be an issue, depending on use.

good point, you definitely want to either throttle events that are being outsourced to another script, or just use the touch_start/touch_end to trigger their start and stop.
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
07-20-2009 07:03
From: Void Singer
good point, you definitely want to either throttle events that are being outsourced to another script, or just use the touch_start/touch_end to trigger their start and stop.
The problem with that is that people expect the hold action to fire after they've held it long enough. If people just have to guess that they've held it long enough they'll get frustrated, or hold it way too long.
_____________________
Argent Stonecutter - http://globalcausalityviolation.blogspot.com/

"And now I'm going to show you something really cool."

Skyhook Station - http://xrl.us/skyhook23
Coonspiracy Store - http://xrl.us/coonstore
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
07-20-2009 09:42
From: Argent Stonecutter
The problem with that is that people expect the hold action to fire after they've held it long enough. If people just have to guess that they've held it long enough they'll get frustrated, or hold it way too long.

so you throttle it AFTER you send the message (with llSleep), or if you use triggers from the start and end if doesn't matter.
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
07-20-2009 10:25
From: Void Singer
so you throttle it AFTER you send the message (with llSleep), or if you use triggers from the start and end if doesn't matter.
Or you just abort the whole transaction if someone else tries to jump the gun, which is what I'd do if I wasn't building a HUD where that case can't happen.
_____________________
Argent Stonecutter - http://globalcausalityviolation.blogspot.com/

"And now I'm going to show you something really cool."

Skyhook Station - http://xrl.us/skyhook23
Coonspiracy Store - http://xrl.us/coonstore