UI / Accessing button name from another button

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
lcfan
Posts: 5
Joined: Mon May 16, 2016 3:42 pm

UI / Accessing button name from another button

Post by lcfan » Mon May 16, 2016 3:50 pm

Short version: Is there some documentation of how UI elements are accessed?

(This is riffing off the code example http://forums.livecode.com/viewtopic.php?f=7&t=11750).
If I have two buttons, start and stop, how do I access start from stop?

Here's the code - this is in the button 'stop':

Code: Select all

on mouseUp
   if the label of start = "cntr" then 
      set the label of start to "stop"
   end if
end mouseUp
PS, it would be awesomesauce if someone could point me to a video or article on debugging Livecode. Tx in advance.

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: UI / Accessing button name from another button

Post by Klaus » Mon May 16, 2016 4:00 pm

Hi lcfan,

1. welcome to the forum! :D

2. use the KIND and NAME (or number or ID) when addressing objects in LC:

Code: Select all

...
if the label of BUTTON "start" = "cntr" then 

      ## Or save some typing and use the abbreviation -> btn
      set the label of btn "start" to "stop"
end if
...
This way you can also access objects that are NOT on the current card or even in the current stack:
...
set the label of btn "another button" of cd "another card not in THIS stack" of stack "yet another stack" to "another label..."
...
Like a correct address on a (postal) letter!
Means: Wrong address = no delivery!

3. Please check these stacks to learn more about the very basics of Livecode:
http://www.hyperactivesw.com/revscriptc ... ences.html
There is also a DEBUGGING sexample stack!


Best

Klaus

lcfan
Posts: 5
Joined: Mon May 16, 2016 3:42 pm

Re: UI / Accessing button name from another button

Post by lcfan » Mon May 16, 2016 4:34 pm

Thank you! I've reviewed the link you sent.

How do I see the current label of the button "start"? That is, have it show up here: <I don't have permission to post imgur links :( >

That is, can I set a watch on start.label (or whatever it's called), or even better, watch it and trigger a conditional breakpoint?

All the best.

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: UI / Accessing button name from another button

Post by Klaus » Mon May 16, 2016 4:51 pm

lcfan wrote:... That is, have it show up here: <I don't have permission to post imgur links :( >...
Yes, you need at least 10 postings before you can post links or attachments here, due to spam protection!
lcfan wrote:How do I see the current label of the button "start"? That is, have it show up here: <I don't have permission to post imgur links :( >
That is, can I set a watch on start.label (or whatever it's called), or even better, watch it and trigger a conditional breakpoint?
All the best.
Sorry, really no idea what you are asking for?
Please try to get used to the Livecode terminology if possible.

lcfan
Posts: 5
Joined: Mon May 16, 2016 3:42 pm

Re: UI / Accessing button name from another button

Post by lcfan » Mon May 16, 2016 4:54 pm

Yep, I'm learning it. It is pretty different.

Let me restate: How do I see the value of the button "start"'s label?

The code is in debug mode, and a breakpoint has been triggered. Is there a place where I can see the current value of the "start" button's label?

Thanks

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: UI / Accessing button name from another button

Post by Klaus » Mon May 16, 2016 5:03 pm

Hi lcfan,

AHA! :D

Not per se!
You will need to put the label into a (temporary) variable to see its value in the debugger!

But maybe you are looking for something like this to simply "switch" the appropriates labels:

Code: Select all

...
if the label of BUTTON "start" = "cntr" then 

      ## Or save some typing and use the abbreviation -> btn
      set the label of btn "start" to "stop"
     ## Do your stuff for this condition...
ELSE
      set the label of btn "start" to "cntr"
      ## And for this one if neccessary...
end if
...
Best

Klaus

lcfan
Posts: 5
Joined: Mon May 16, 2016 3:42 pm

Re: UI / Accessing button name from another button

Post by lcfan » Mon May 16, 2016 5:37 pm

Thank you. Interestingly, not doing what I expected, which tells me something about how variables are handled, but that's for me to learn.

Where am I able to give feedback to LiveCode, and is that effective? This debugger is lacking some features that are considered basic in modern IDEs, and that's probably going to compromise my coding enjoyment. It might be a contributing factor as to why I have seen so few larger / more complex code.

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: UI / Accessing button name from another button

Post by Klaus » Mon May 16, 2016 6:17 pm

Hi lcfan,
lcfan wrote:Where am I able to give feedback to LiveCode, and is that effective?
not sure what you mean?!
There is a bug and feature request database online here:
http://quality.livecode.com
Maybe that is what you are looking for.


Best

Klaus

lcfan
Posts: 5
Joined: Mon May 16, 2016 3:42 pm

Re: UI / Accessing button name from another button

Post by lcfan » Mon May 16, 2016 6:42 pm

Thank you. I appreciate your help.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: UI / Accessing button name from another button

Post by jacque » Tue May 17, 2016 4:25 pm

Can you tell us what features you would want to see in the debugger? Some of them may be there already but not immediately intuitive.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply