Reply
Honored Resident
Publik
Posts: 26
0 Kudos

Ctrl+Drag an object within bounds AND touch events

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.

Member
Miranda Umino
Posts: 259
0 Kudos

Re: Ctrl+Drag an object within bounds AND touch events

[ Edited ]

Reply to Publik - view message

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

 

 

Qie Niangao
Posts: 5,069
Registered: ‎02-25-2009
0 Kudos

Re: Ctrl+Drag an object within bounds AND touch events

Reply to Publik - view message

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.

Honored Resident
Publik
Posts: 26
0 Kudos

Re: Ctrl+Drag an object within bounds AND touch events

[ Edited ]

Reply to Qie Niangao - view message

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

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?

Posts: 294
Topics: 11
Blog Posts: 0
Ideas: 0
Registered: ‎02-08-2010

Re: Ctrl+Drag an object within bounds AND touch events

[ Edited ]

Reply to Publik - view message

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).

Honored Resident
Publik
Posts: 26
0 Kudos

Re: Ctrl+Drag an object within bounds AND touch events

[ Edited ]

Reply to Rufus Darkfold - view message

touch(integer numDetected)
{
vector grabOffset = llDetectedGrab(0);
if(llVecMag(grabOffset) > 0.001)
{
llSetPos(llGetPos() + grabOffset);
}
}

This seems to work, albeit it's kinda jerky. Any way to smooth it out?

Honored Resident
Publik
Posts: 26
0 Kudos

Re: Ctrl+Drag an object within bounds AND touch events

[ Edited ]

Reply to Publik - view message

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

Contributor
Cerise Sorbet
Posts: 2,497

Re: Ctrl+Drag an object within bounds AND touch events

Reply to Publik - view message

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);
        }
    }
}

 

Honored Resident
Publik
Posts: 26
0 Kudos

Re: Ctrl+Drag an object within bounds AND touch events

[ Edited ]

Reply to Cerise Sorbet - view message

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.

Contributor
Cerise Sorbet
Posts: 2,497
0 Kudos

Re: Ctrl+Drag an object within bounds AND touch events

Reply to Publik - view message

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.