Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

The better double-click

Geuis Dassin
Filming Path creator
Join date: 3 May 2006
Posts: 565
01-14-2007 22:40
CODE

touch_start(integer total_number)
{
clickcount++;
if(clickcount == 1){
first_time = llGetUnixTime();
}
if(clickcount == 2 && (first_time == llGetUnixTime())){
//do your code here
llOwnerSay("dblclick");



clickcount = 0;
}
if(clickcount > 2 || first_time != llGetUnixTime()){
clickcount = 0;
first_time = 0;
}
}
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Discussion thread
01-15-2007 23:14
/54/06/160770/1.html
_____________________
i've got nothing. ;)
Domino Marama
Domino Designs
Join date: 22 Sep 2006
Posts: 1,126
01-16-2007 02:35
I can't see what cases this will catch that something simple like this won't.

CODE

integer first_time = 0;

default
{
touch_start(integer num_detected)
{
if ( first_time == llGetUnixTime() )
{
first_time = 0;
// double clicked code here
}
else
{
first_time = llGetUnixTime();
}
}
}


Both versions have two problems:

1) Multiple avatars clicking at the same time give a false double click
2) A valid double click close to the end of a second won't register, ie llGetUnixTime increases in the time between clicks.