Change the current card title bar

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

michel_bujardet
Posts: 45
Joined: Mon Apr 21, 2014 10:41 am
Contact:

Change the current card title bar

Post by michel_bujardet » Fri Apr 25, 2014 9:44 pm

How do I change the title bar of the current card ?

I tried

Code: Select all

set the title of this card to "test"
But it generates an error when run :(

Mitch
http://FontMenu.com

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

Re: Change the current card title bar

Post by dunbarx » Fri Apr 25, 2014 10:57 pm

Hi.

There are two pertinent properties you should know. One is the "name" of a stack, and the other is its "title" (or label). There is no VISIBLE card name, though cards certainly can be named. But those names are object references only, and though very useful, do not appear in the titlebar.

Now since the label is a property of a stack that stands apart from its name, it might be fun indeed to write a handler that changes the title (of the stack) according to which card you are on. This sounds like cheating, but is definitely not. Can you write such a thing? What will you use to identify each card? Could be anything at all, including the card's name.

More importantly, do you see the differences between these properties?

Write back. I am interested in seeing what you come up with.

Craig Newman

michel_bujardet
Posts: 45
Joined: Mon Apr 21, 2014 10:41 am
Contact:

Re: Change the current card title bar

Post by michel_bujardet » Sat Apr 26, 2014 7:11 am

dunbarx wrote:Now since the label is a property of a stack that stands apart from its name, it might be fun indeed to write a handler that changes the title (of the stack) according to which card you are on. This sounds like cheating, but is definitely not.
Your posting put me on the track. I looked in the dictionary, and sure enough found what I needed :

Code: Select all

   set the title of this stack to "my title"
This can be set in the openCard message when the card opens, so each card has an identifiable window title.

Mitch
http://FontMenu.com

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

Re: Change the current card title bar

Post by dunbarx » Sat Apr 26, 2014 4:37 pm

Right on.

You could use any attribute of each card to drive the title of the stack. it could be the contents of a background field, the name of the card, or any other card-specific property.

You could, of course, change the name of the stack, as opposed to its title. But this is pure pedantry. Don't. Just don't.

Craig

michel_bujardet
Posts: 45
Joined: Mon Apr 21, 2014 10:41 am
Contact:

Re: Change the current card title bar

Post by michel_bujardet » Sat Apr 26, 2014 9:01 pm

dunbarx wrote: You could, of course, change the name of the stack, as opposed to its title. But this is pure pedantry. Don't. Just don't.
Frankly, I do not see why I would ever want to change the name of the stack...

Mitch
http://FontMenu.com

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

Re: Change the current card title bar

Post by dunbarx » Sat Apr 26, 2014 9:30 pm

Precisely.

The effect, for your purposes, would be same, if you did not set the "title" property at all. That was my only point, so that you see all the possibilities. But this is fraught with peril, and may well require a layer of management that is totally unnecessary.

Craig

michel_bujardet
Posts: 45
Joined: Mon Apr 21, 2014 10:41 am
Contact:

Re: Change the current card title bar

Post by michel_bujardet » Sat Apr 26, 2014 9:43 pm

dunbarx wrote:The effect, for your purposes, would be same, if you did not set the "title" property at all. That was my only point, so that you see all the possibilities. But this is fraught with peril, and may well require a layer of management that is totally unnecessary.
To quote Isaac Asimov in "The Non-A" : "The map is not the territory".

The displayed title bar should not be the name of the card, IMHO. I am not going to change my name to "Hi, I'm Mike". Am going to change the badge ;)

Mitch
http://FontMenu.com

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

Re: Change the current card title bar

Post by dunbarx » Sat Apr 26, 2014 11:21 pm

Michel.

I agree. I would always opt for a backGround title field of some kind, rather than change the titlebar itself. It flies in the face of all standard UI guidelines, and certainly those of Apple. But that is a matter of style. My effort is to teach.
The displayed title bar should not be the name of the card
So then what did you have in mind with your very first post? You asked for a way to change the titlebar. We can do that now. If not the name of the card, then something else of interest, I assume? I had suggested several possible attributes that might serve.

Craig Newman

michel_bujardet
Posts: 45
Joined: Mon Apr 21, 2014 10:41 am
Contact:

Re: Change the current card title bar

Post by michel_bujardet » Sat Apr 26, 2014 11:57 pm

dunbarx wrote:So then what did you have in mind with your very first post? You asked for a way to change the titlebar. We can do that now. If not the name of the card, then something else of interest, I assume? I had suggested several possible attributes that might serve.
I have been programming for years in all flavors of Basic (since 1982) including RealBasic now Xojo, and am simply playing around with LiveCode. I follow patiently the tutorials, but exercise around much, to feel more comfortable. For instance today I have created a short method to display time zone and cities from the Windows system
http://forums.runrev.com/viewtopic.php?f=18&t=20191
I found all I needed in the dictionary, and enjoyed a rather easy coding :)

Along the way, I wondered how to get the same result as basic instr() , could not find anything in the dictionary, not here either, and finally discovered through an internet search a discussion where I got FoundChunk which provided precisely that.

Some people play chess, others fill crossword puzzles, I enjoy programming. When I post a question I do not necessarily expect a ready made piece of code, but rather informations, sometimes simply terminology, which will get me on the way.

The titlebar question came from the "Navigating around a stack" tutorial. I noticed individual cards, in fact full fledged windows to the user with different appearance and controls, did not have a title property. It would make sense for instance to have the title of a window to be "The Application", "Settings", the other "Editor" and so on...

Mitch
http://FontMenu.com

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

Re: Change the current card title bar

Post by dunbarx » Sun Apr 27, 2014 2:32 am

Ah.

I have never gone through any tutorials. Those users who have come from that starting point frequently have me at a disadvantage; they have lessons and techniques that they use as a foundation that I am likely competent in, but do not base my thinking around.

Anyway, it will happen again and again, You will find yourself needing a tool, and discover that such a gadget often already exists, as you found out. Or that it is easily crafted. The hard part is describing the problem. But this community has endless patience. Do keep playing. I bet you will soon find LC irresistible.

By the way, in your openCard handler, what attribute of each card did you use to change the title property?

Craig Newman

michel_bujardet
Posts: 45
Joined: Mon Apr 21, 2014 10:41 am
Contact:

Re: Change the current card title bar

Post by michel_bujardet » Sun Apr 27, 2014 6:11 am

dunbarx wrote:By the way, in your openCard handler, what attribute of each card did you use to change the title property?
Curious. I thought you knew, as I originally requested it and posted a tentative code : I changed the title of the stack in each card.

Mitch
http://FontMenu.com

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

Re: Change the current card title bar

Post by dunbarx » Sun Apr 27, 2014 2:50 pm

I still do not understand. I see you have an opencard handler, presumably in the stack script. But this sets the title of the stack ubiquitously to "My Title". If I were doing it, then for argument's sake let us assume I had a background field on each card (this could be hidden) that had some unique piece of data. Let us name this field "titleField":

Code: Select all

on opencard
set the title of this stack to field "titleField"
end openCard
Now the title changes to reflect the value of the contents of the field every time you navigate to a different card. Again, this field is resident on each card, but has unique data on each card (sharedText set to "false").

Wasn't the intent to change the title based on the specific card the user is looking at? Or am I missing the whole thing?

Craig

michel_bujardet
Posts: 45
Joined: Mon Apr 21, 2014 10:41 am
Contact:

Re: Change the current card title bar

Post by michel_bujardet » Sun Apr 27, 2014 5:28 pm

dunbarx wrote:I still do not understand. I see you have an opencard handler, presumably in the stack script. But this sets the title of the stack ubiquitously to "My Title". If I were doing it, then for argument's sake let us assume I had a background field on each card (this could be hidden) that had some unique piece of data. Let us name this field "titleField":

Code: Select all

on opencard
set the title of this stack to field "titleField"
end openCard
Now the title changes to reflect the value of the contents of the field every time you navigate to a different card. Again, this field is resident on each card, but has unique data on each card (sharedText set to "false").

Wasn't the intent to change the title based on the specific card the user is looking at? Or am I missing the whole thing?
That is precisely what the code does in the openCard message : change the title of the stack, so it changes the window title according to which card is on the screen.

The "My Title" thing in the code I posted is there for the sake of illustration. It is in no way intended to be ubiquitous. On the contrary. Cards having no title property, I have to set the stack title, but what I want is to have a different title for each card. In reality, as I tried to explain, it will reflect the nature of the card : 'Main screen', 'Settings', 'History', whatever...

Mitch
http://FontMenu.com

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

Re: Change the current card title bar

Post by dunbarx » Sun Apr 27, 2014 6:20 pm

OK. So now I see that your "My title" one-liner was sort of pseudocode.

I just was asking how you stored, or accessed, the various different titles. Are they local and explicit to "openCard" handlers in each card script? There is nothing wrong with this, I suppose. But if so, then I would suggest thinking of a far more compact and robust method, where a single openCard handler in the stack script uses attributes of each card. One handler, local attributes, instead of multiple handlers, no attributes.

I still do not know if this is how you implemented your project. Or some other way entirely. Just curious, though.

Craig

michel_bujardet
Posts: 45
Joined: Mon Apr 21, 2014 10:41 am
Contact:

Re: Change the current card title bar

Post by michel_bujardet » Sun Apr 27, 2014 8:43 pm

dunbarx wrote:I just was asking how you stored, or accessed, the various different titles. Are they local and explicit to "openCard" handlers in each card script? There is nothing wrong with this, I suppose. But if so, then I would suggest thinking of a far more compact and robust method, where a single openCard handler in the stack script uses attributes of each card. One handler, local attributes, instead of multiple handlers, no attributes.

I still do not know if this is how you implemented your project. Or some other way entirely. Just curious, though.
Craig, I am not at the app design yet. I posted in the beginners section because I am still discovering LC and originally did not understand why I could not change the card title (which does not exist).

I am still at the exercising stage where I simply accumulate experience with diverse aspects of LC to later use the new gained ease of use in creating an app.

Today I went through the http://lessons.runrev.com/s/lessons/m/4 ... al-effects tutorial and built a three cards small app with one picture on each and visual slow dissolve and push left and right transitions.

In such apps where each card displays a few different screens, if a generalized stack handler seems more OOP and could be considered more elegant, a single line in each card's openCard message is probably just as efficient and easy to read.

For a bigger app I want to create with dozens of pictures, it may be better to have a unique, more generalized handler.

I will see when I get there... :)

Image

Mitch
http://FontMenu.com

Post Reply