Jump to content

Ctrl+Drag an object within bounds AND touch events


Publik
 Share

You are about to reply to a thread that has been inactive for 4523 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I want to Click-Drag an object (Ctrl + Left Click) and have touch events. Currently the touch events grab the left click, even when Ctrl is pressed. Are there ways to filter this out, so I can have my dragging and my touch event? The touch events are time-sensitive and handle deleting the object I'm working on and can be changed to some other command if need be, but I'd rather not.

Link to comment
Share on other sites

Ctrl + Left Click  are not detectable .

 

Nevertheless , you can catch

-> + left click

<- + left click

PgUp key + left click

PgDown key + left click

and some others

 

In fact only  a few keys are detected . And the right button mouse can t be detected neither .

 

Check this wiki

http://wiki.secondlife.com/wiki/Control

 

If you do a Jira to do a request to add some keys or some mouse events , let me a message to vote it

 

Other point : if you need to have an event because your prim has moved ( in a general way not only by cntrl + left click), you can detect it yet . For instance , by catching the events moving_start and moving_end

http://wiki.secondlife.com/wiki/Moving_start

 

 

Link to comment
Share on other sites

Ctrl + Left Click  are not detectable .

 

Nevertheless , you can catch

-> + left click

<- + left click

PgUp key + left click

PgDown key + left click

and some others

 

In fact only  a few keys are detected . And the right button mouse can t be detected neither .

 

Check this wiki

http://wiki.secondlife.com/wiki/Control

 

If you do a Jira to do a request to add some keys or some mouse events , let me a message to vote it

 

Other point : if you need to have an event because your prim has moved ( in a general way not only by cntrl + left click), you can detect it yet . For instance , by catching the events moving_start and moving_end

http://wiki.secondlife.com/wiki/Moving_start

 

 

Link to comment
Share on other sites

If it's not critical that it use the built-in Control+Drag movement -- that is, if you don't mind it being dragged around without the Control key being pressed -- then you may get what you need from llDetectedGrab() inside a touch() event, using some threshold on time or offset to determine those cases when only a touch was intended.

Link to comment
Share on other sites

If it's not critical that it use the built-in Control+Drag movement -- that is, if you don't mind it being dragged around without the Control key being pressed -- then you may get what you need from llDetectedGrab() inside a touch() event, using some threshold on time or offset to determine those cases when only a touch was intended.

Link to comment
Share on other sites

That seems about right, I'll give it a try :)

touch(integer numDetected){    if(llDetectedGrab(0) == ZERO_VECTOR)    {        // touched?    }}

 The only problem I can see with this is if I grab it but don't move it... And I'd prefer using the built in grab; I want nice fluid controls that don't need menus or commands.

 

Edit: Not a fix, it disables the click-drag action and replaces it with touch. I guess I could have a touch-once to open movement (which goes to a new state that has no touch events) and then let you touch again to lock it down? Can I allow-disallow people to be able to click-drag through LSL?

Link to comment
Share on other sites

That seems about right, I'll give it a try :)

touch(integer numDetected){    if(llDetectedGrab(0) == ZERO_VECTOR)    {        // touched?    }}

 The only problem I can see with this is if I grab it but don't move it... And I'd prefer using the built in grab; I want nice fluid controls that don't need menus or commands.

 

Edit: Not a fix, it disables the click-drag action and replaces it with touch. I guess I could have a touch-once to open movement (which goes to a new state that has no touch events) and then let you touch again to lock it down? Can I allow-disallow people to be able to click-drag through LSL?

Link to comment
Share on other sites

It won't move by itself then,  but you can move it in your touch event if you detect that it is being dragged more than some tiny amount.

I use this in my HUDs so I can more them around on the screen easily.

(though note the llDetectedGrab is rather broken for HUDs,  often (but not always) returning negative coordinates due to the current local position being subtracted twice).

  • Like 1
Link to comment
Share on other sites

So here's what I've got as a little test:

float dragMinAmount = 0.001;float time = 0.0;integer dragging = FALSE;float waitTime = 2.0;default{    state_entry()    {        dragging = FALSE;    }        touch_start(integer numDetected)    {        time = llGetTime();    }        touch(integer numDetected)    {        vector dragOffset = llDetectedGrab(0);        if(llVecMag(dragOffset) > dragMinAmount)        {            dragging = TRUE;            llSetPos(llGetPos() + dragOffset); // (1)        }                if(!dragging)        {            if(llGetTime() - time > waitTime)            {                llOwnerSay("Time exceded");            }        }                }        touch_end(integer numDetected)    {        llOwnerSay("Time reset, drag stopped");        dragging = FALSE;        time = 0.0;    }}

 It seems to work, but I've had a few little bugs that I can't seem to get to reliably replicate. One was where it started driving off in a direction, as if it was looped at (1). Another seemed to do something similar, except I still had control over the object. I could move it around, but it looked like it thought it's position was at the same point, so the offset wasn't from the current position. Can anyone give insight or toss some tips my way?

 

Edit: Something interesting I've noticed. This works with simple touch (LMB) as well as drag (CTRL + LMB), but the former only moves it on the X

Link to comment
Share on other sites

If your situation allows it, you might make the object physical on touch_start and back to nonphysical on touch_end.  This kills the crab allows you to use a real grab.  Then a regular mouse hold, ctrl not required, will allow grab movement without too much extra work.

 

default{    touch_start(integer total_number)    {        if (llDetectedKey(0) == llGetOwner())        {            llOwnerSay("touchy!!!!");            llSetStatus(STATUS_PHYSICS, TRUE);        }    }        touch_end(integer total_number)    {        if (llDetectedKey(0) == llGetOwner())        {            llSetStatus(STATUS_PHYSICS, FALSE);        }    }}

 

  • Like 1
Link to comment
Share on other sites

Oh, wow, that's definitely smoother. The only problem with that is that it's physical so it can get knocked around. With what I have, the complete code locks the object onto a plane. It's jerky but it keeps it locked right. Would there be ways to restrict physical movement on the axii? I know I can with rotation.

Link to comment
Share on other sites

To prevent collisions you can use use llSetStatus(STATUS_PHYSICS|STATUS_PHANTOM, TRUE) on the touch_start, then llSetStatus(STATUS_PHYSICS|STATUS_PHANTOM, FALSE) on touch_end. There is no good way with this method to prevent grabs in all 3 directions if the user wants to do that, but you could save the Z position before the grab is allowed, then restore it with llSetPos at the end.

Link to comment
Share on other sites

With SL3 , put the attributes of gravity to 0 .

So  , it will move only on the XY plane

 

And on LSL  use PRIM_PHYSICS_MATERIAL inside llSetLinkPrimitiveParamsFast

 

PRIM_PHYSICS_MATERIAL 31 Sets the prim's physics material properties. [ PRIM_PHYSICS_MATERIAL, integer material_bits, float gravity_multiplier, float restitution, float friction, float density ]
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4523 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...