no mouseup message passed

Deploying to Mac OS? Ask Mac OS specific questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
roeg11
Posts: 4
Joined: Fri Jul 31, 2009 4:01 pm

no mouseup message passed

Post by roeg11 » Wed Aug 05, 2009 2:37 pm

I'm building a very simple little program for language learning called a "cloze." In it I ask the user to drag and drop a button into a sentence that has a blank. The button has the script :

on mousedown
repeat while the mouse is down
set the loc of card button "dragndrop" to the mouseloc
end repeat
end mousedown


on mouseup
if the loc of me is within the rectangle of field "dropsite"
then
answer "You've got it!" with "Close me."
exit mouseup
else set the loc of me to 10,30
end mouseup


It sometimes resets the button to the right loc and sometimes not. So I opened the message watcher, and saw that sometimes mouseup doesn't appear. Why is that? I've searched the forum and didn't find an answer (at least not one I could apply to my simple situation):
the field is not locked and it's in the background (or second level)
Thanks in advance
new (exam copy) user
roeg11

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Wed Aug 05, 2009 3:55 pm

Dear roeg11,

Why don't you simply put the syntax from the mouseUp handler at the end of the mouseDown handler? That will work for sure.

Best regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4171
Joined: Sun Jan 07, 2007 9:12 pm

Post by bn » Wed Aug 05, 2009 3:58 pm

Hi Roeg,

welcome to the forum.

try:

Code: Select all

on mousedown
 grab me
end mousedown
instead of your "repeat until"
I never get the mouseup in the messagewatcher. I suppose it is because your repeat tests for the mouse beeing down. When the mouse is actually up your mousedown handler ends. So probably it gobbled up your mouseUp event. Grab me is just what you want.

BTW you dont need to write "card button". Actually it will not hurt but be aware that that is a Hypercard word. Revolution does not distinguish between background and card in the syntax, although you can create groups with background behaviour, you still address the buttons and field as just button and field.

You will see that once you get used to Revolution it has a lot to offer that Hypercard could not at the time.

Be aware that Revolution does not like blocking handlers, like you did in your repeat structure. It effectively locks up the engine. Which for a short time is not a problem, but if you process a lenghty repeat structure it can become one. Look in the resource center under applications the scripts of a blocking and a non blocking count down for an example.



regards

Bernd

roeg11
Posts: 4
Joined: Fri Jul 31, 2009 4:01 pm

Post by roeg11 » Wed Aug 05, 2009 7:03 pm

Mark wrote:Dear roeg11,

Why don't you simply put the syntax from the mouseUp handler at the end of the mouseDown handler? That will work for sure.

Best regards,

Mark
funny you should suggest that, that's exactly what I did with something like "send mouseup to cd btn...." and it works every time now! and the drop function too.

I think I'm going to like this program and this forum and all your expertise!
cheers

Post Reply