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!
I'm a little confused with the messages path. The doc and the "messages hierarchy" stack of the scripting conference say about background "put after cd in message path"
In this example FromBG and FromCD work fine. I expected an error with FromBG
I have a bg with this script (tested withh rev 4.0 and liveCode 4.5
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
I send a message "FromBG" from the messagesBox to a background
For me the hierarchic position of this message is after the script of the card
FromBG send (not with the send command") a message and the card catch it
If the hierarchic position of bg script is after the card script then the card can't catch
I tested this with 4.0. If I set the backgroundBehavior of a group to true, it should catch messages after the card receives them, but if I send a message directly to the group, I wouldn't expect the card to catch the message, because the card comes before the group. Yet, it does.
-- group script:
on foo
put cr & "group" after msg
pass foo
end foo
-- cd script:
on foo
put cr & "card" after msg
pass foo
end foo
-- stack script:
on foo
put cr & "stack" after msg
end foo
I have set the backgroundBehavior of the group to true.
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 message path order for backgrounds has been revised slightly (in a backwards-compatible fashion) to take proper account of passing of messages. For a control within a background, the message path is the following:
target
target's owning groups
target's background
card
card's backgrounds not including the target's background
stack
The path for a message sent to a background is:
target background
card
card's backgrounds not including the target's background
stack
Note: The above order effectively means that a background's script is only behind the card for controls it does not contain which retains compatibility with previous interpretations of backgroundBehavior.
This is introduced in 4.6.1
Everything should be clear now
Wouldn't it be a nice question in a Livecode certification examination?, right next to the question: The seven meanings of stack.
No, this isn't entirely clear yet. What if the stack is a HyperCard stack? In that case, all controls are included in one background. According to the docs you just posted, the messages go to the bg before they go to the card. This breaks HyperCard stacks, if I understand it correctly.
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
I see your point, one would have to try it with a Hypercard stack. Unfortunately I can not test this.
but doesn't this preserve Hypercards message path?
The above order effectively means that a background's script is only behind the card for controls it does not contain which retains compatibility with previous interpretations of backgroundBehavior
A Hypercard card control (outside of a background, or in Hypercards case the only background) gets a message. If it is not processed then the card gets the message and then the background. I think it should work with Hypercard stacks.
Kind regards
Converted HyperCard stacks contain only one background per card, which contains all background objects of that card (I checked this by opening an old HyperCard stack in Revolution). If messages from objects in groups are sent to the group before they are sent to the card, this will break HyperCard stacks. From what you posted before, I understand that this is indeed the case. For former HyperCard users, the situation with the bug was probably more useful than the situation with the modified message path.
I just opened an old stack in Revolution 3.5. In Rev 3.5, if I send a message to a card, the card script runs before the background script, as expected. If I send the message to the background, the card script runs after the background script. Apparently it was buggy already and it still is, just in a different way
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 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 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
I tested the converted Hypercard stack you sent me.
If I click on the button "click me" which is part of the background the message box returns
background
card
I added a new card button, which is not part of the background and the message box returns
card
background
If I remember correctly this is the behaviour you would expect from a Hypercard stack assuming that a message from a member of the background is handled in the background script. If it is not handled by a background script there might be a problem if you catch it on the card script level.
To not break HyperCard stacks, you should only get
background
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