Show card title in title bar of stack

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

Post Reply
Bruce27
Posts: 7
Joined: Thu Nov 08, 2018 11:49 am

Show card title in title bar of stack

Post by Bruce27 » Thu Nov 08, 2018 12:02 pm

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

Klaus
Posts: 13821
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Show card title in title bar of stack

Post by Klaus » Thu Nov 08, 2018 1:04 pm

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

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Show card title in title bar of stack

Post by bogs » Thu Nov 08, 2018 2:51 pm

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

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9648
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Show card title in title bar of stack

Post by dunbarx » Thu Nov 08, 2018 2:54 pm

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

Bruce27
Posts: 7
Joined: Thu Nov 08, 2018 11:49 am

Re: Show card title in title bar of stack

Post by Bruce27 » Thu Nov 08, 2018 10:00 pm

Thank you, Klaus, bogs and Craig for those very helpful suggestions. That solves my problem!

Regards
Bruce

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”