UserInput Mouseup and Doublemouseup

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: UserInput Mouseup and Doublemouseup

Post by Mag » Thu Feb 20, 2014 11:58 pm

Ok, here is a try, I tried to develop your suggestion to store the first keystroke, is much less than perfect, it would be great if someone could improve it a bit... :lol:
Attachments
Keys.livecode.zip
(1.11 KiB) Downloaded 147 times

trevix
Posts: 950
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: UserInput Mouseup and Doublemouseup

Post by trevix » Mon Jan 30, 2023 12:03 pm

Hello.
I have to add a "hold" to the all thing and I came up with the following.
Beside the evident dealy on single click, it works on desktop. Now I will try it on mobile...
Any improvement suggestion will be welcomed.

Code: Select all

local sMouseDownTime, sFlag

on mouseUp pMouseButton
     put true into sFlag
     send "mouseUpStuff" to me in the doubleClickInterval milliseconds
end mouseUp


on mouseDoubleUp pButtonNumber
     put false into sFlag
     put "double click" & cr after msg
     beep
     --do stuff here
     
end mouseDoubleUp


on mouseDown pButtonNumber
     put the seconds into sMouseDownTime    
end mouseDown

on mouseStillDown pButtonNumber
     if sMouseDownTime is not empty AND the seconds - sMouseDownTime >= 2 then
          put "hold" & cr after msg
          put empty into sMouseDownTime
          beep
          --do stuff here
          
     end if
end mouseStillDown

on mouseUpStuff
     if sMouseDownTime is not empty  then
          if the seconds - sMouseDownTime >= 2 then
               put "hold" & cr after msg
          else
               if sFlag then
               put "1 click" & cr after msg
              beep
               --do stuff here
               
               end if
          end if
     end if
end mouseUpStuff
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9567
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: UserInput Mouseup and Doublemouseup

Post by dunbarx » Mon Jan 30, 2023 3:41 pm

Trevix.

Did you mean to jump into a 12 year old thread?

Anyway, what are you trying to do? The handlers you posted detect a double click within the doubleClickInterval.

The original thread dealt with distinguishing between single and double clicks. I never felt comfortable including both a mouseUp and a mouseDoubleUp handler in the same script, which is why I mentioned this dodge. And this was developed over 30 years ago, in HC, where there was no "mouseDoubleUp" message at all.

Craig

trevix
Posts: 950
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: UserInput Mouseup and Doublemouseup

Post by trevix » Mon Jan 30, 2023 4:51 pm

Yes sir. I meant since the thread dealt with click and double click but did not consider hold, that, in my umble opinion, is part of the all :D .

My standalone on mobile, connects with sockets to a remote standalone (on mobile too).
The mobile A shows a screenShot (received from B) and should allow the user to do a 1Click, a double click and a hold, that get transmitted to mobile B.
This has to be done with a single button on mobile A, for several reasons that regards the UX.

My finding is that my script works well on OSX, not so on mobile.

On iOS hardware, "single click" and "hold" work fine, but "double click" sometime reports two times "single click", no matter how is the interval in between the two touches.
Not sure what is the pattern that explain while sometimes it works and sometimes it doesn't. It seems tough that if the two touches interval is too short or too long, I get twice single click. So, it could be my code...

on Android hardware, is, more or less as in iOS: double click are randomly obtained. In this was the speed of the two touches has a less relevant effect
Any help is appreciated.

Trevix
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9567
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: UserInput Mouseup and Doublemouseup

Post by dunbarx » Mon Jan 30, 2023 5:30 pm

OK.

But have you tried the solution I posted early on:

Code: Select all

on mouseup
    wait 20
    if the mouseClick then
    beep 2
    --doDoubleStuff
  else
    beep 1
    --doSingleStuff
    end if
end mouseUp
Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9567
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: UserInput Mouseup and Doublemouseup

Post by dunbarx » Mon Jan 30, 2023 5:32 pm

As noted, the "20" is just a value I made up. The "doubleClickInterval" likely is more grown-up.

Craig

trevix
Posts: 950
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: UserInput Mouseup and Doublemouseup

Post by trevix » Mon Jan 30, 2023 7:08 pm

Apparently the MouseClick trows an error on Android.
On iOS the double click doesn't work at all.
On OSX works fine.

Any idea?
See attached example.
Thanks
Attachments
TestVariousClicks.livecode.zip
(2 KiB) Downloaded 53 times
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9567
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: UserInput Mouseup and Doublemouseup

Post by dunbarx » Mon Jan 30, 2023 7:13 pm

Trevix.

I don't work in mobile. I can barely talk on one.

Someone here might know if the "mouseClick" is not a supported mobile function.

Craig

trevix
Posts: 950
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: UserInput Mouseup and Doublemouseup

Post by trevix » Mon Jan 30, 2023 7:18 pm

The dictionary says it is...
I will submit a bug report
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9250
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: UserInput Mouseup and Doublemouseup

Post by richmond62 » Mon Jan 30, 2023 7:30 pm

I'd just have a FIELD (perhaps call it 'Klaus') to hold a sign if the mouse has been clicked once, so a second click has either NO effect or runs another script.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3975
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: UserInput Mouseup and Doublemouseup

Post by bn » Mon Jan 30, 2023 8:47 pm

trevix wrote:
Mon Jan 30, 2023 7:08 pm
On iOS the double click doesn't work at all.
On OSX works fine.

Any idea?
See attached example.
Thanks
Trevix,

for the doubleClick to work on iOS you have to set the "doubleClickDelta" to a value around 10 to 12 from the default 4.

Because on mobile the finger is not as precise as a mouse or a trackpad. I.e. the second click for "double" might easily be more than 4 pixel away

From the dictionary

doubleClickDelta
Type property

Syntax
set the doubleClickDelta to numberOfPixels
Also have a look at the doubleClickInterval

Kind regards
Bernd

trevix
Posts: 950
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: UserInput Mouseup and Doublemouseup

Post by trevix » Tue Jan 31, 2023 11:09 am

Thanks for the very useful suggestion.
I tested my script on various Android versions and apparently they react differently to the DoubleClickInterval.
I guess it dipends on the processor, the OS version, the screen, else.
Since my standalone should work on Android 9> and iOS 12>, it is going probably to be very difficult to set this value for each device...
I give up. I will have to find a different solution...

Regards

Code: Select all

local sMouseDownTime

on mouseUp pMouseButton
     put "up" & cr after fld "LabelEdit" of the owner of me
     if sMouseDownTime is not empty  then
          send "mouseUpStuff" to me in the doubleClickInterval milliseconds
     end if
end mouseUp

on mouseDoubleUp pButtonNumber
     put empty into sMouseDownTime
     put "double click" & cr after fld "LabelEdit" of the owner of me
     beep
     --do stuff here
     put last char of the short name of me into tNum
     
end mouseDoubleUp

on mouseDown pButtonNumber
     put "down" & cr after fld "LabelEdit" of the owner of me
     if sMouseDownTime is empty then
          put the seconds into sMouseDownTime    
     end if
end mouseDown

on mouseStillDown pButtonNumber
     if sMouseDownTime is not empty AND (the seconds - sMouseDownTime) >= 2 then
          put empty into sMouseDownTime
          put "hold"  & cr after fld "LabelEdit" of the owner of me
          beep
          --do stuff here
          put last char of the short name of me into tNum
     end if
end mouseStillDown

on mouseUpStuff --single click
     if sMouseDownTime is not empty then
          put "1 click" & cr after fld "LabelEdit" of the owner of me
          beep
          --do stuff here
          put last char of the short name of me into tNum
          
     end if
end mouseUpStuff
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3975
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: UserInput Mouseup and Doublemouseup

Post by bn » Tue Jan 31, 2023 11:17 am

Trevi,

I think the doubleClickDelta is more important than the doubleClickInterval. Try to set that to 10 or 12 in an openStack handler and see what happens.

Kind regards
Bernd

trevix
Posts: 950
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: UserInput Mouseup and Doublemouseup

Post by trevix » Tue Jan 31, 2023 11:21 am

Yes, I did in the openstack and it really changed everything.
But the behaviour of the DoubleClick Interval is still too different on different devices...
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>

trevix
Posts: 950
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: UserInput Mouseup and Doublemouseup

Post by trevix » Tue Jan 31, 2023 2:34 pm

May be...
Setting the parameters in the PreOpenstack like this:

Code: Select all

set the doubleClickDelta to 20
     if the environment = "Mobile" then
          set the doubleClickInterval to 400
     end if
This code seems to work on all mobile platform and OSX, even tough not so much reactive.I am also not sure the flushEvent("mouseDown") is sorting any effect.

Code: Select all

local sFlagStop,sMouseDownTime

on mouseDown pButtonNumber
     --put "down" & cr after fld "LabelEdit" of the owner of me
     if not sFlagStop then
          send "mouseUpStuff" to me in the doubleClickInterval milliseconds
          put the seconds into sMouseDownTime
     end if
end mouseDown

on mouseDoubleUp pButtonNumber
     put true into sFlagStop
     put "double click" & cr after fld "LabelEdit" of the owner of me
     beep
     --do stuff here
     put last char of the short name of me into tNum
     wait 3 seconds --fake other script running
     
     put flushEvents("mouseDown") into temp
     send "SetTheFlag false" to me in 1 seconds
end mouseDoubleUp

on mouseStillDown pButtonNumber
     --put "mouseStillDown" & cr after fld "LabelEdit" of the owner of me
     if sMouseDownTime is not empty AND (the seconds - sMouseDownTime) >= 2 then
          put true into sFlagStop
          put empty into sMouseDownTime
          put "hold"  & cr after fld "LabelEdit" of the owner of me
          beep
          --do stuff here
          put last char of the short name of me into tNum
          
          send "SetTheFlag false" to me in 1 seconds
     end if
end mouseStillDown

on mouseUpStuff --single click
     if not sFlagStop AND the mouse is not down then
          put "1 click" & cr after fld "LabelEdit" of the owner of me
          beep
          --do stuff here
          put last char of the short name of me into tNum
          wait 3 seconds  --fake other script running
     end if
end mouseUpStuff

On SetTheFlag pValue
     put pValue into sFlagStop --avoid another mousedown
end SetTheFlag
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”