MouseUp subroutine won't run
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
MouseUp subroutine won't run
I made a group that has two entry fields in it. In the group I put a one line mouseUp subroutine (beep). When I click the group nothing beeps. What did I do wrong?
Dear Janey,
Could you please post your script?
Groups don't catch mouseUp messages by themselves. The message has to be caught by a button, field or card before it can be passed on to the group.
A card will pass on the mouseUp message to a group, only if the backgroundBehavior of the group is set to true (see property inspector).
Best,
Mark
Could you please post your script?
Groups don't catch mouseUp messages by themselves. The message has to be caught by a button, field or card before it can be passed on to the group.
A card will pass on the mouseUp message to a group, only if the backgroundBehavior of the group is set to true (see property inspector).
Best,
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
Sure
Janey
Code: Select all
on mouseUp
beep
end mouseUp
Section 5.5.9 in the user's guide seems to be saying that groups do catch messages. Setting that property just changes if it is before the card or after it I think. The control gets the message before the group no matter what the property is set to. But if there are no subs before the group which catch the message and don't pass it on, the group should get the message, right?Groups don't catch mouseUp messages by themselves. The message has to be caught by a button, field or card before it can be passed on to the group.
A card will pass on the mouseUp message to a group, only if the backgroundBehavior of the group is set to true (see property inspector).
Janey
Dear Janey
Messages must be generated by an object to be passed on to a group. If you chance a group into a background, it suddenly catches all messages after they are passed on by a card. Since a card can receive messages, even if these messages are not generated by buttons or fields, the card will pass on the message to the background.
Malte is right about fields not receiving the mouseUp message, if the lockText of the field is false. To handle a mouseClick on a card, only if that click happened within a group, you might try the following:
This does what I think you described in your original post.
Best,
Mark
This is slightly wrong. The backgroundBehavior property can turn a group into a "real" background. Groups really are just a collection of objects and catch any message after the object has caught it and before the object passes that message on to a card. However, if there is no object, there is no message to pass on to the card, hence there is no message caught by the group.Section 5.5.9 in the user's guide seems to be saying that groups do catch messages. Setting that property just changes if it is before the card or after it I think.
Messages must be generated by an object to be passed on to a group. If you chance a group into a background, it suddenly catches all messages after they are passed on by a card. Since a card can receive messages, even if these messages are not generated by buttons or fields, the card will pass on the message to the background.
Malte is right about fields not receiving the mouseUp message, if the lockText of the field is false. To handle a mouseClick on a card, only if that click happened within a group, you might try the following:
Code: Select all
on mouseUp
if the mouseLoc is within the rect of grp "Your Group" then
beep
end if
end mouseUp
Best,
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
It turns out I needed to set the lockfield to true. From the dictionary
Comments:
When a field's lockText property is false, the field can be edited: the user can select text, delete text, type, cut, copy, and paste. The cursor becomes an I-beam when the mouse pointer is over the field. When the user clicks in the field, no mouseDown, mouseUp, mouseStillDown, mouseDoubleDown, or mouseDoubleUp messages are sent. (However, if the user Control-clicks or right-clicks, these messages are sent regardless of the field's lockText setting.)
Janey,
A real background is one that catches all the messages that get to the card first, just the way it works in HyperCard. In other words, a group with the backgroundBehavior set to true :-)
Best,
Mark
A real background is one that catches all the messages that get to the card first, just the way it works in HyperCard. In other words, a group with the backgroundBehavior set to true :-)
Best,
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