Jump to content

single/double click detection


revochen Mayne
 Share

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

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

Recommended Posts

This script detects if it gets touched once or twice within a short period of time.

 

float touchTime = 0.3;


list touchKeys = [];
list touchTypes = [];

default
{

    touch_start(integer total_number)
    {
        key who = llDetectedKey(0);
        if(llListFindList(touchKeys,[who])==-1)
        {
            touchKeys += who;
            touchTypes += "singleTouch";
            llSetTimerEvent(touchTime);
        }
        else
        {
            integer i = llListFindList(touchKeys,[who]);
            touchTypes = llListReplaceList(touchTypes,["doubleTouch"],i,i);
        }
    }
    
    timer()
    {
        integer i = 0;
        integer m = llGetListLength(touchKeys);
        llSetTimerEvent(0);
        while(i<m)
        {
            if(llList2String(touchTypes,i)=="singleTouch")
            {
                // do something on single touch
                llSay(0, "Thanks for your single touch "+llKey2Name(llList2Key(touchKeys,i))+"!");
            }
            else
            {
                // do something on double touch
                llSay(0, "Thanks for your double touch "+llKey2Name(llList2Key(touchKeys,i))+"!");
            }
            ++i;
        }
        touchKeys = [];
        touchTypes = [];
    }
}

 

 

 

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4414 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...