Header bar widget question

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
ValiantCuriosity
Posts: 128
Joined: Thu Jun 30, 2016 3:08 am

Header bar widget question

Post by ValiantCuriosity » Sat Feb 09, 2019 7:22 pm

So, here comes another one of those pesky multitude of newbie questions:

I've searched the forum and read and re-read the header bar section of the docs. I've tried using the recommended code to change a title on an individual card to no avail. Here is what I am doing:

I have 4 cards. The header bar is grouped and used on three of the cards. I want to change the title via code to display a different title (Label?) on one card. I've searched the forum and found this code:

Code: Select all

set the label of widget "your header bar here..." to "New Title..."
I tried placing it in my "HeaderBarGroup", but nothing changes when I change the card from card 2 to card 3.

I've also tried looking at

Code: Select all

set the itemLabels of widget to labels
I don't really understand how to use this bit of code and there is no example.

I looked in the Guide section at the Header Bar. It talks about how to change the "buttons". That worked for me. :D However, there was no example of changing the Title/Label for only one card/page.

Can someone point me in the right direction or help answer this coding question for me?

Thanks again for all the help and support. Maybe, just maybe, if I can learn and use LC for development, I can give a little back to the forum -- eventually. :wink:
May I never be cured of my curiosity! :D

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

Re: Header bar widget question

Post by Klaus » Sat Feb 09, 2019 7:45 pm

The widget does not get notified if you/your user changes the card, so the script will never get "triggered", you need to put your code into the card script of the card where you want to have another title!

Code: Select all

on opencard
   set the label of widget "your header bar here..." to "New Title..."
end opencard
And of course you need to reset the title when leaving this namely card:

Code: Select all

on closecard
   set the label of widget "your header bar here..." to "The Old Title..."
end closecard
I highly recommend to go through these stacks to get the very basics of LC:
http://www.hyperactivesw.com/revscriptc ... ences.html
The lessons are a bit older, so no widgets in them.

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

Re: Header bar widget question

Post by Klaus » Sat Feb 09, 2019 7:48 pm

Code: Select all

set the itemLabels of widget to tLabels
There seems to be an error in the dictionary, it MUST read:

Code: Select all

set the itemLabels of widget "NAME OF WIDGET HERE IN ANY CASE!" to tLabels
We ALWAYS have to add the number or name of the control we want to address!

ValiantCuriosity
Posts: 128
Joined: Thu Jun 30, 2016 3:08 am

Re: Header bar widget question

Post by ValiantCuriosity » Sun Feb 10, 2019 4:59 am

I've bookmarked the link that you suggested. Thank you Klaus.

There is so much information to sift through. Some of the docs have errors. When I find them, I send a note to support. I know LC people are so busy that docs probably aren't a huge priority, but it is the only way that I can try to give back as I'm learning.

-Rachel
May I never be cured of my curiosity! :D

bwmilby
Posts: 438
Joined: Wed Jun 07, 2017 5:37 am
Location: Henrico, VA
Contact:

Re: Header bar widget question

Post by bwmilby » Sun Feb 10, 2019 5:34 am

That convention is very prevalent in widget docs. The word “widget” usually means that you need to properly reference a particular widget as you suggested.
Brian Milby

Script Tracker https://github.com/bwmilby/scriptTracker

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

Re: Header bar widget question

Post by Klaus » Sun Feb 10, 2019 1:45 pm

bwmilby wrote:
Sun Feb 10, 2019 5:34 am
That convention is very prevalent in widget docs. The word “widget” usually means that you need to properly reference a particular widget as you suggested.
Yes, but this is only in the widget docs and the result is that new users copy and paste these code snippets and are wondering "ad ultimo" why it does not work! See this thread! :?

bwmilby
Posts: 438
Joined: Wed Jun 07, 2017 5:37 am
Location: Henrico, VA
Contact:

Re: Header bar widget question

Post by bwmilby » Sun Feb 10, 2019 3:50 pm

Agree. I’ll probably need to do a massive PR to fix them all.
Brian Milby

Script Tracker https://github.com/bwmilby/scriptTracker

ValiantCuriosity
Posts: 128
Joined: Thu Jun 30, 2016 3:08 am

Re: Header bar widget question

Post by ValiantCuriosity » Wed Feb 13, 2019 12:31 am

I highly recommend to go through these stacks to get the very basics of LC:
http://www.hyperactivesw.com/revscriptc ... ences.html
The lessons are a bit older, so no widgets in them.
This link should be made into a sticky for the Complete Beginner's section of the board.

Thanks for pointing it out @Klaus.
-Rachel
May I never be cured of my curiosity! :D

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”