wait 20
if the mouseClick then
answer "beep 2"
--doDoubleStuff
else
answer "beep 1"
--doSingleStuff
end if
UserInput Mouseup and Doublemouseup
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: UserInput Mouseup and Doublemouseup
Just tested in iOS and it doesn't work. In desktop works fine.
-
- VIP Livecode Opensource Backer
- Posts: 7247
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: UserInput Mouseup and Doublemouseup
Can't speak for iOS, but in Craig's original handler you could get a more reliable and usually faster response if you test for the doubleClickInterval rather than the hard-coded "20". Twenty ticks is a fair amount of delay, the default doubleclick interval is only about 8 ticks. Since the interval can be set by the developer, 20 may be too short or too long, but testing the doubleClickInterval should give the fastest allowable responses.
Code: Select all
wait the doubleclickinterval milliseconds
if the mouseClick then
-- etc
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: UserInput Mouseup and Doublemouseup
Hi Jacque, interesting considerations.
PS
Anyway the problem with iOS is that just don't work the code, maybe it's a bug.
PS
Anyway the problem with iOS is that just don't work the code, maybe it's a bug.
Re: UserInput Mouseup and Doublemouseup
Here is the stack.
- Attachments
-
- mouseClick.livecode.zip
- (1.43 KiB) Downloaded 170 times
-
- VIP Livecode Opensource Backer
- Posts: 7247
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: UserInput Mouseup and Doublemouseup
Interesting. Error 252 is "error in if-then condition" and error 624 is "wait aborted". I don't know if that's a bug or a technical limitation. It's odd though because it implies that the check for a mouse click is happening before the wait completes.
You can find the LiveCode Error Lookup stack in the User Samples area. It's a convenient way to find what those cryptic numbers mean when you're debugging. Errors are listed with the most recent one at the top, with the error chain leading up to it listed in reverse order underneath. The first number in each line is the error code to look up; the second number is the line number of the script where the error occured, the third is the character position. So, error 252 is the if-then error, which occurs on line 4 of the script at character 1. (If it's character 1, it usually means the line can't be processed at all.) The top-most error is the one that finally caused the script to stop ("wait aborted.")
I generally avoid the whole double-click issue by not assigning both mouseUp and mouseDoubleUp handlers to the same object. Is that possible in your stack design?
You can find the LiveCode Error Lookup stack in the User Samples area. It's a convenient way to find what those cryptic numbers mean when you're debugging. Errors are listed with the most recent one at the top, with the error chain leading up to it listed in reverse order underneath. The first number in each line is the error code to look up; the second number is the line number of the script where the error occured, the third is the character position. So, error 252 is the if-then error, which occurs on line 4 of the script at character 1. (If it's character 1, it usually means the line can't be processed at all.) The top-most error is the one that finally caused the script to stop ("wait aborted.")
I generally avoid the whole double-click issue by not assigning both mouseUp and mouseDoubleUp handlers to the same object. Is that possible in your stack design?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: UserInput Mouseup and Doublemouseup
Hi jacque, thank you so much for the very useful info, I really love be able now to read the errors! I will download the errors stack.
PS
Unfortunately in this case not, I'm creating a mobile app with an image gallery, where user aspects that a single tap hides and shows the navBar and the toolBar; a double-tap switch the image between actual size and full screen.
PS
Unfortunately in this case not, I'm creating a mobile app with an image gallery, where user aspects that a single tap hides and shows the navBar and the toolBar; a double-tap switch the image between actual size and full screen.
-
- VIP Livecode Opensource Backer
- Posts: 7247
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: UserInput Mouseup and Doublemouseup
I haven't tested this much but you could tinker with something like this:
Code: Select all
local sFlag
on mouseUp
put true into sFlag
send "mouseUpStuff" to me in the doubleClickInterval milliseconds
end mouseUp
on mouseDoubleUp
put false into sFlag
-- doubleUp stuff here
end mouseDoubleUp
on mouseUpStuff
if sFlag = true then
-- mouseUp stuff here
end if
end mouseUpStuff
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: UserInput Mouseup and Doublemouseup
Thank you Jacqueline, I will try it right now!
-
- VIP Livecode Opensource Backer
- Posts: 858
- Joined: Wed Jun 24, 2009 1:17 pm
- Location: Plymouth, UK
- Contact:
Re: UserInput Mouseup and Doublemouseup
Craig - thanks for this trick
dunbarx wrote:I have alsways used the old HC method:
on mouseup
wait 20
if the mouseClick then
beep 2
--doDoubleStuff
else
beep 1
--doSingleStuff
end if
end mouseUp
This old fashioned method bypasses the issues that putting a mouseUp and a mouseDoubleUp handler in the same script.
I have even extended this to allow triple clicks (and beyond).
Craig Newman
"...this is not the code you are looking for..."
Re: UserInput Mouseup and Doublemouseup
Works nice, thank you jacque!jacque wrote:I haven't tested this much but you could tinker with something like this:
Code: Select all
local sFlag on mouseUp put true into sFlag send "mouseUpStuff" to me in the doubleClickInterval milliseconds end mouseUp on mouseDoubleUp put false into sFlag -- doubleUp stuff here end mouseDoubleUp on mouseUpStuff if sFlag = true then -- mouseUp stuff here end if end mouseUpStuff
Re: UserInput Mouseup and Doublemouseup
... and... If I wanted to create a field that accepts only two characters, and I wanted to wait to see if the user type 1 or 2 keys before placing them in the field? This is even more difficult isn't it?
-
- VIP Livecode Opensource Backer
- Posts: 9689
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: UserInput Mouseup and Doublemouseup
This wins the bronze for kluges. As an experiment, make a button and a field. Name the field "F1". In the button script:
In the field script:
Now this works, but gets constipated easily. Too much finagling in the guts. But maybe it will give you evil ideas.
Craig
Code: Select all
on mouseUp
put "" into fld "f1"
set the singleChar of fld "f1" to ""
end mouseUp
Code: Select all
on keydown var
if the singleChar of me = "" then
set the singleChar of me to var
select text of me
else
put the singleChar of me & var into me
set the singleChar of me to ""
end if
end keydown
Craig
Re: UserInput Mouseup and Doublemouseup
Very interesting, now we need a way to register a interval so that you understand when the user wants to enter only one digit instead of two...
-
- VIP Livecode Opensource Backer
- Posts: 9689
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: UserInput Mouseup and Doublemouseup
I hear rumblings in the gut.
With this sort of required functionality, perhaps it might be better to display an "ask" dialog, where it says:
"Enter two characters..."
And then when the user clicks "OK" you can validate the string and take the appropriate action, either to load the field, or to excoriate the user.
Craig
With this sort of required functionality, perhaps it might be better to display an "ask" dialog, where it says:
"Enter two characters..."
And then when the user clicks "OK" you can validate the string and take the appropriate action, either to load the field, or to excoriate the user.
Craig
Re: UserInput Mouseup and Doublemouseup
Yes, or maybe with a beep.
I think, however, your idea to store the first key can grow up and become the solution. Maybe with something like this:
I store the first key.
If it do not arrive another press key within a specified time.
Send key in the field.
Otherwise, sends the two keys in the field.
I think, however, your idea to store the first key can grow up and become the solution. Maybe with something like this:
I store the first key.
If it do not arrive another press key within a specified time.
Send key in the field.
Otherwise, sends the two keys in the field.