Page 1 of 1

MouseUp subroutine won't run

Posted: Wed Jul 29, 2009 7:19 pm
by Janey
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?

Posted: Wed Jul 29, 2009 8:21 pm
by Mark
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

Posted: Wed Jul 29, 2009 8:42 pm
by Janey
Sure

Code: Select all

on mouseUp
beep
end mouseUp
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).
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?

Janey

Posted: Wed Jul 29, 2009 8:43 pm
by malte
If you click into the field and want to hear your beep, try focusin instead of mouseup. Unlocked fields do not trigger mouseup. Fields only do if the locktext property of the field is true.

All the best,

Malte

Posted: Wed Jul 29, 2009 9:20 pm
by Mark
Dear Janey
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.
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.

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
This does what I think you described in your original post.

Best,

Mark

Posted: Wed Jul 29, 2009 9:25 pm
by Janey
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.)

Posted: Wed Jul 29, 2009 9:27 pm
by Janey
woops I didn't read me replies before I posted.

Posted: Wed Jul 29, 2009 9:30 pm
by Janey
This is slightly wrong. The backgroundBehavior property can turn a group into a "real" background.
What do you mean a "real" background?

Janey

Posted: Wed Jul 29, 2009 10:41 pm
by Mark
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