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
no mouseup message passed
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
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
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
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Hi Roeg,
welcome to the forum.
try: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
welcome to the forum.
try:
Code: Select all
on mousedown
grab me
end mousedown
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
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.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
I think I'm going to like this program and this forum and all your expertise!
cheers