Page 1 of 1

Show card title in title bar of stack

Posted: Thu Nov 08, 2018 12:02 pm
by Bruce27
I'm just starting out with LiveCode, so I'm trying to get to know the basics. Here is a very basic question (if you don't mind).

If I have a stack with more than one card in it, is there a way of showing the name of the current card in the title bar of the stack. As I have it, only the name of the stack shows in the title bar, so I have to look at the Card Inspector or the Project Browser to find the name of the topmost card (i.e. the one which I am working on). It would make things a lot easier if the name of the card were shown in the title bar next to the name of the stack.

Thanks in advance
Bruce

Re: Show card title in title bar of stack

Posted: Thu Nov 08, 2018 1:04 pm
by Klaus
Hi Bruce,

welcome to the forum! :D

Put this into your stack script:

Code: Select all

on preopencard
  set the title of this stack to the short name of this cd
end preopencard
If one or more of your cards already have a "preopencard" script, then add this line at the end of these handlers:

Code: Select all

on preopencard
  ## Do your thing here...
  ## and here...
  pass preopencard
end preopencard
Best

Klaus

Re: Show card title in title bar of stack

Posted: Thu Nov 08, 2018 2:51 pm
by bogs
Bruce27 wrote:
Thu Nov 08, 2018 12:02 pm
It would make things a lot easier if the name of the card were shown in the title bar next to the name of the stack.
It sounds to me like you are looking to show both the stack name and card name, something like this:
My Stack Program - Card Name

There are a number of ways to accomplish it, depending on how you setup the main stack. Using Klaus's code, for instance, you could do ~

Code: Select all

on preopencard
# if the stack has no label, and is using a name only...
  set the title of this stack to the short name of this stack && "-" && the short name of this cd
# if your stack has a label set...
   set the title of this stack to the label of this stack && "-" && the short name of this cd
# if you want the stack title to be a string of your choosing aside from the name or label...
     set the title of this stack to "My new made up title -" && the short name of this cd
end preopencard
Just pick one of the above and it should be what your looking for.

Re: Show card title in title bar of stack

Posted: Thu Nov 08, 2018 2:54 pm
by dunbarx
HI.

What Klaus said.

And it will become important later to know that the "name" of a control, like a button or field, is different than its 'label". "Title", for a stack, is similar to the "label" of a control.

This is common practice, not to change the names of controls (and stacks) for reference, but to use their "labels" (or "titles", for stacks) for display to the user. Labels change with the needs of the UI. Names generally are held constant.

Craig Newman

Re: Show card title in title bar of stack

Posted: Thu Nov 08, 2018 10:00 pm
by Bruce27
Thank you, Klaus, bogs and Craig for those very helpful suggestions. That solves my problem!

Regards
Bruce