Control groups - different button labels per card

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
rjenkinsgb
Posts: 12
Joined: Tue Feb 17, 2015 1:30 pm

Control groups - different button labels per card

Post by rjenkinsgb » Tue May 05, 2015 4:03 pm

Hi,
I have a nice auto-size toolbar working & set as a group / background so it appears on new cards.

However, despite hours of experimentation & google searches I cannot figure out how to have different button labels on each card with the grouped controls.
It does not matter which card or instance of the group I select, changing a button label changes it on all cards.

Is it possible to pre-define different labels on each card or do I have to consider it more like a softkey system where labels and actions are processed by a common handler for the whole application?

I have seen "in passing" mention on another site that the buttons in a group can have per-card properties, but I'm totally stuck on how or where you set these...

RJ.

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

Re: Control groups - different button labels per card

Post by Klaus » Tue May 05, 2015 4:16 pm

Hi RJ,
rjenkinsgb wrote:I have seen "in passing" mention on another site that the buttons in a group can have per-card properties, but I'm totally stuck on how or where you set these...
unfortunately LABEL or NAME are not per-card properties of buttons!
You will need to write some "preopencard" handler(s) to create the correct labels for your buttons per card.


Best

Klaus

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

Re: Control groups - different button labels per card

Post by dunbarx » Tue May 05, 2015 10:46 pm

Hi.

What Klaus said.

Fields can have "local" or "global" contents, based on the value of their sharedText property, but the labels of controls are "global". So unless you overlay a field onto a button, or create some other new composite control, then, as Klaus says, the only way forward is to load the appropriate information during navigation, based on data accessed in your own manner.

Craig Newman

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9833
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Control groups - different button labels per card

Post by FourthWorld » Tue May 05, 2015 11:17 pm

LiveCode is very fast.

Suppose you had a list of button labels as a custom property in each card, something like:

buttonName1,buttonLabel1
buttonName2,buttonLabel2
buttonName3,buttonLabel3
etc...

Then you could have a preOpenCard handler in your stack like this:

Code: Select all

on preOpenCard
  put the uBtnLabels of this cd into tList
  repeat for each line tLine in tList
    put item 1 of tLine into tBtnName
    if there is a btn tBtnName then
      set the label of btn tBtnName to (item 2 of tLine)
    end if
   end repeat
   pass preOpenCard
end preOpenCard
LiveCode can process hundreds of controls like that in a fraction of a second.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

rjenkinsgb
Posts: 12
Joined: Tue Feb 17, 2015 1:30 pm

Re: Control groups - different button labels per card

Post by rjenkinsgb » Wed May 06, 2015 9:48 am

What I've actually done is re-name the buttons to something generic, eg. Key01, Key02 etc.

I've only got four buttons at present.

There is no need to re-name them from card to card - it's easier to know what they are & use the same info in every card..

on preOpenCard
set the label of Key01 to "whatever it is for this card"
set the label of Key02 to "blah"
... etc
end preOpenCard

on Key01
[do the action for that button on this card - just the name of the command in the main program]
end Key01

on Key02
[do that action]
etc..


The only parts that need changing from card to card are the label texts and the actions / commands called when that button is used.
(Each button has an on mouseup that calls it's own name as an action).


I was originally thinking I would need a centralised handler, but as I started on the card scripts I realised that the way livecode messages work, a handler within each card would get the key actions first so they can be re-sent to do appropriate things with minimal code.

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”