MouseUp subroutine won't run

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Janey
Posts: 9
Joined: Wed Jul 29, 2009 6:29 pm

MouseUp subroutine won't run

Post by Janey » Wed Jul 29, 2009 7:19 pm

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?

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

Post by Mark » Wed Jul 29, 2009 8:21 pm

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
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

Janey
Posts: 9
Joined: Wed Jul 29, 2009 6:29 pm

Post by Janey » Wed Jul 29, 2009 8:42 pm

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

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Contact:

Post by malte » Wed Jul 29, 2009 8:43 pm

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

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

Post by Mark » Wed Jul 29, 2009 9:20 pm

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
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

Janey
Posts: 9
Joined: Wed Jul 29, 2009 6:29 pm

Post by Janey » Wed Jul 29, 2009 9:25 pm

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
Posts: 9
Joined: Wed Jul 29, 2009 6:29 pm

Post by Janey » Wed Jul 29, 2009 9:27 pm

woops I didn't read me replies before I posted.

Janey
Posts: 9
Joined: Wed Jul 29, 2009 6:29 pm

Post by Janey » Wed Jul 29, 2009 9:30 pm

This is slightly wrong. The backgroundBehavior property can turn a group into a "real" background.
What do you mean a "real" background?

Janey

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

Post by Mark » Wed Jul 29, 2009 10:41 pm

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
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

Post Reply