OpenCard to control?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Zax
Posts: 519
Joined: Mon May 28, 2007 10:12 am
Contact:

OpenCard to control?

Post by Zax » Sat May 04, 2024 11:01 am

Hello,

When a card is opened, it receives the "openCard" message.
Is it possible that different controls of this card also automatically receive the "openCard" message when opening this card?
Of course, I could send "openCard" to the desired controls by "send" or "dispatch" but I don't know which controls should receive this message.

Well, maybe that's not very clear. In summary, how do I place a control in the Message Path so that it receives the "openCard" message, without modifying the card script - I would like these controls to be independent and can be easily copied to different stacks without modifying the scripts of cards or stacks.

Klaus
Posts: 13982
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: OpenCard to control?

Post by Klaus » Sat May 04, 2024 11:04 am

Hi Zax,

unfortunaltely there is no such message.

However we have a "opencontrol" message, but that is only sent to GROUPS.
But maybe you can use this somehow by just grouping one or more of your controls. :)

Best

Klaus

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9762
Joined: Fri Feb 19, 2010 10:17 am

Re: OpenCard to control?

Post by richmond62 » Sat May 04, 2024 11:20 am

Of course, I could send "openCard" to the desired controls by "send" or "dispatch" but I don't know which controls should receive this message.
Well . . .

Code: Select all

on OpenCard
      send "mouseUp" to button "myButton"
end openCard

Zax
Posts: 519
Joined: Mon May 28, 2007 10:12 am
Contact:

Re: OpenCard to control?

Post by Zax » Sat May 04, 2024 12:41 pm

Klaus wrote:
Sat May 04, 2024 11:04 am
However we have a "opencontrol" message, but that is only sent to GROUPS.
But maybe you can use this somehow by just grouping one or more of your controls. :)
Great!
Thanks a lot Klaus, it's just perfect :D


This picture, found at https://lessons.livecode.com/m/4603/l/5 ... ssage-path needs to be updated.

Image

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10013
Joined: Wed May 06, 2009 2:28 pm

Re: OpenCard to control?

Post by dunbarx » Sun May 05, 2024 11:18 pm

Zax. You should inform Jacque that the "direction" of that diagram is upside down. She will appreciate the news.

Craig

Zax
Posts: 519
Joined: Mon May 28, 2007 10:12 am
Contact:

Re: OpenCard to control?

Post by Zax » Mon May 06, 2024 6:59 am

dunbarx wrote:
Sun May 05, 2024 11:18 pm
Zax. You should inform Jacque that the "direction" of that diagram is upside down. She will appreciate the news.
Is she a Diana Ross fan? :wink:

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7320
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: OpenCard to control?

Post by jacque » Mon May 06, 2024 6:39 pm

A long time ago one member referred to us as either sky worshippers or earth somethings. Wish I could remember the exact labels, it was clever. I am firmly bound to the earth but over the years I have learned to flip the vision the sky worshippers cling to. If that fails I use Google translate.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Zax
Posts: 519
Joined: Mon May 28, 2007 10:12 am
Contact:

Re: OpenCard to control?

Post by Zax » Tue May 07, 2024 9:03 am

I found a more accurate diagram (but I don't know if the earth and the sky are rightly placed ;) )

Image

stam
Posts: 2996
Joined: Sun Jun 04, 2006 9:39 pm

Re: OpenCard to control?

Post by stam » Tue May 07, 2024 9:44 am

The obvious omission in that graph is behaviors.
it's especially useful to know that the a handler will be executed first in the object carrying the behavior and then only executed in the behavior if not handled or passed in the carrying object.

I'm not sure double the graph like the one you show helps actually - the right handed graph basically interjects the substack, but actually the way I think of it is that it goes to stack (regardless if substack or not) so you can illustrate the path as card > substack > stack, a single graph.

The other omissions are front- and backscripts, both are essential.

Richard has written a very nice piece on the message path you can find here: http://www.fourthworld.com/embassy/arti ... _path.html

This figure below from his write-up probably illustrates most detail, but not quite everything (eg that cards, backgrounds & scripts can have behaviors too). I'm not sure if cards have precedents to background groups as this graph suggests (may be an older version where such a thing as 'background' existed), in my mind, group scripts (whether background or not) occur earlier in the message path than card - but happy to be corrected...

The other good thing to know is that backscripts intercept the message path from multiple mainstacks.


Image
Last edited by stam on Tue May 07, 2024 10:38 am, edited 1 time in total.

stam
Posts: 2996
Joined: Sun Jun 04, 2006 9:39 pm

Re: OpenCard to control?

Post by stam » Tue May 07, 2024 10:33 am

Thinking about this more, here's a proposal for a more complete message path - happy to be corrected if I got something wrong or missed something...

LC message path.jpg

Where a path component is missing, go to next component, seems to ring true to me.
I assume widgets/script widgets are included in "Control" but not sure.
I'm also unsure as to if "background group" is higher up the message path than "card" which many graphs indicate. Seems odd to me, but haven't got the time to experiment right now...

I guess the obvious caveat is startup is sent to the 1st card of the stack, but not sure how that would be represented...
Also now sure how to represent linked behaviors... maybe I'll change the word "Behavior" to "Behavior(s)".

Zax
Posts: 519
Joined: Mon May 28, 2007 10:12 am
Contact:

Re: OpenCard to control?

Post by Zax » Tue May 07, 2024 11:55 am

I do not have sufficient knowledge to correct the validity of the information in this diagram but if it is correct, I suggest using the color code from the previous diagrams (notably yellow for optional elements).
And if it is correct, this diagram should appear on the official LC help, replacing the very incomplete diagram that I posted first.

stam
Posts: 2996
Joined: Sun Jun 04, 2006 9:39 pm

Re: OpenCard to control?

Post by stam » Tue May 07, 2024 12:02 pm

Zax wrote:
Tue May 07, 2024 11:55 am
I do not have sufficient knowledge to correct the validity of the information in this diagram but if it is correct, I suggest using the color code from the previous diagrams (notably yellow for optional elements).
And if it is correct, this diagram should appear on the official LC help, replacing the very incomplete diagram that I posted first.
yeah I posted this as a proposal for people who know more than me to feed back.
Certainly, it's how I use LiveCode and it seems to work ;)

As to the notion of colouring 'optional' steps - the only 'non-optional' elements of this is the starting point, the stack and the engine , so I'd probably colour those instead ;)
(you don't need any of the other elements, but if present will follow the message path)

One thing that is not clearly represented is that scripts in the backscripts will affect any stack running on a given engine, so it accepts multiple inputs (I've used this when having multiple script only library stacks and not wanting to create a web of connected libraries with 'start using' - just ensure handlers are namespaced and it works a charm).

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9960
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: OpenCard to control?

Post by FourthWorld » Tue May 07, 2024 2:54 pm

Behaviors can also be nested.

The most complete representation is a vast spiderweb of connections, less instructive than a simplified model designed for learning core concepts.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7320
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: OpenCard to control?

Post by jacque » Tue May 07, 2024 5:45 pm

@stam: Cards receive messages before backgrounds if the group has background behavior set. If not then they behave like other controls and get messages before the card but after the controls the group contains.

I am delighted to see that you and Richard are earth lovers. 🙂

Edit: I don't think opencard is sent to card groups, it's sent to the card. If a background group has an opencard handler then it will catch the message if the card doesn't. Richard's diagram shows both types of groups and seems accurate.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

stam
Posts: 2996
Joined: Sun Jun 04, 2006 9:39 pm

Re: OpenCard to control?

Post by stam » Tue May 07, 2024 6:34 pm

FourthWorld wrote:
Tue May 07, 2024 2:54 pm
Behaviors can also be nested.

The most complete representation is a vast spiderweb of connections, less instructive than a simplified model designed for learning core concepts.
Agreed, which is why I didn't add anything, and the multiple behavior boxes seem annoying as well, but also seem necessary. I think many users, especially new users, miss the opportunity to use these.

In an effort to at least imply possibility of nested behaviors, I think changing Behavior to Behavior(s) can help flag this.

AnthonyKoor wrote:
Tue May 07, 2024 3:46 pm
You can set a custom property at the card level and then check for it in the controls' script. If it's there, they'll respond accordingly to the "openCard" message.
Thanks Anthony - that is of course correct, but it's not part of the normal message path. As it happens, groups are sent the 'openControl' message at openCard, which is why this is included.

The idea is to show the hierarchy of objects that messages pass through when dispatched.

jacque wrote:
Tue May 07, 2024 5:45 pm
@stam: Cards receive messages before backgrounds if the group has background behavior set. If not then they behave like other controls and get messages before the card but after the controls the group contains.
Noted - thank you. I'll add a further 'background group' level after the card. I see also that backgrounds have the equivalent of openControl (openBackground). Learn something new every day ;)


So here's a revised version of the message path.
Yellow are the 'less commonly used elements', as the only required elements are stack and engine really...

Is this closer to accurate?
LC message path.jpg

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”