Page 1 of 1

UI / Accessing button name from another button

Posted: Mon May 16, 2016 3:50 pm
by lcfan
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.

Re: UI / Accessing button name from another button

Posted: Mon May 16, 2016 4:00 pm
by Klaus
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

Re: UI / Accessing button name from another button

Posted: Mon May 16, 2016 4:34 pm
by lcfan
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.

Re: UI / Accessing button name from another button

Posted: Mon May 16, 2016 4:51 pm
by Klaus
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.

Re: UI / Accessing button name from another button

Posted: Mon May 16, 2016 4:54 pm
by lcfan
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

Re: UI / Accessing button name from another button

Posted: Mon May 16, 2016 5:03 pm
by Klaus
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

Re: UI / Accessing button name from another button

Posted: Mon May 16, 2016 5:37 pm
by lcfan
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.

Re: UI / Accessing button name from another button

Posted: Mon May 16, 2016 6:17 pm
by Klaus
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

Re: UI / Accessing button name from another button

Posted: Mon May 16, 2016 6:42 pm
by lcfan
Thank you. I appreciate your help.

Re: UI / Accessing button name from another button

Posted: Tue May 17, 2016 4:25 pm
by jacque
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.