get default button look back after changing button color

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
DasTech
Posts: 6
Joined: Wed Feb 19, 2014 5:23 am

get default button look back after changing button color

Post by DasTech »

Hello all,
This should be an easy one but haven't turned much up in my searches. I have just made an application where I needed to change the color of the button to show the last button pressed. On pressing a new button I would like to change the previous button back to the default color/3d-ish look. Currently I have only figured out how to change the color back to some version of grey and it looks flat. What property of the button am I missing? Is there something like

Code: Select all

set button x to default
?

Thanks for any guidance you may have.

Don
KennyR
Posts: 256
Joined: Thu Jan 19, 2012 4:25 am

Re: get default button look back after changing button color

Post by KennyR »

Hi Don....What I do in this situation is simply this....say you have two buttons and the first button is going to change colors when you press it....then when you press the second button that button changes colors while the first button goes back to its original state....I do this....(group the buttons together so this makes it easier)

Code: Select all

on mouseUp
   repeat with x=1 to the number of btns in grp "name1" without me
      set the backgroundColor of btn x to "#000000"
   end repeat
   if the backgroundColor of me is "#000000" then
      set the backgroundColor of me to "green"
   else
      set the backgroundColor of me to "#000000"
      end if
end mouseUp
KennyR
Posts: 256
Joined: Thu Jan 19, 2012 4:25 am

Re: get default button look back after changing button color

Post by KennyR »

Just as a follow up Don...right click on a button in development mode and select the property inspector. Look at the colors&patterns section and mouse over some of the items there....tool tip will give you handy commands for each section like "textColor" "backGroundColor etc. Open a script up and start fiddling with the settings in a mouseUp handler...

on mouseUp
set the textColor of button "SomeBtn" to "Gold"
set the backGroundColor of button "SomeBtn" to "Black"
end mouseUp

you get the idea..
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: get default button look back after changing button color

Post by Klaus »

Hi Don,

why on earth does noone care to take a look into the dictionary? 8)
The answer is in there, believe me, there is even an example in the dictionary!

Code: Select all

set button x to default
"default" is a property that can be TRUE of FALSE, so the example in the docs is exactly what you are looking for:

Code: Select all

...
set THE DEFAULT of button x to TRUE 
# or FALSE
...
Best

Klaus
KennyR
Posts: 256
Joined: Thu Jan 19, 2012 4:25 am

Re: get default button look back after changing button color

Post by KennyR »

I really need to leave this to the professionals!
DasTech
Posts: 6
Joined: Wed Feb 19, 2014 5:23 am

Re: get default button look back after changing button color

Post by DasTech »

@Klaus
why on earth does noone care to take a look into the dictionary?
Why on earth does no one COMPREHEND what they read. :D
Nice try but wrong answer.

From the dictionary:
Use the default property when designing cards to be used as dialog boxes. The familiar appearance of the default button is a cue to users about what to expect when they use the shortcut of pressing Return or Enter.
This property sets whether or not the button IS THE default button.
What I am after is the default properties of the button.

Thanks for trying though.
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10502
Joined: Wed May 06, 2009 2:28 pm

Re: get default button look back after changing button color

Post by dunbarx »

Klaus, did you see the "without me" that Kenny appended to his repeat structure? This is ignored by the engine, and I was surprised it did not throw an error.

Kenny, "without" is a keyword used in the "move" and "send" commands. Did you include it so as to manage all buttons but the one you clicked on? Cute idea, but no.

Craig Newman
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: get default button look back after changing button color

Post by Klaus »

Hi DasTech,

oh, looks like I misunderstood you completely, sorry for that! :oops:

OK, there are no "default" props for a button, setting them is up to you!

You could store some of the properties (border, back-/forecolor and/or whatever you need to memorize)
and apply this back later.

@Craig
Klaus, did you see the "without me" that Kenny appended to his repeat structure?
No I didn't :D


Best

Klaus
DasTech
Posts: 6
Joined: Wed Feb 19, 2014 5:23 am

Re: get default button look back after changing button color

Post by DasTech »

Cool. Yeah, that will I work if I can figure out how to get that 3d-ish look of the button back.

Thanks Klaus.
DasTech
Posts: 6
Joined: Wed Feb 19, 2014 5:23 am

Re: get default button look back after changing button color

Post by DasTech »

In case anyone is interested I just got what I wanted by doing this:

Code: Select all

set the backgroundColor of button LastButtonPushed to ""
This allowed the button to go back to it's default look and color.
KennyR
Posts: 256
Joined: Thu Jan 19, 2012 4:25 am

Re: get default button look back after changing button color

Post by KennyR »

Craig....Yeah I was trying to have the repeat ignore the button that was being clicked....To me it seemed to work because it resulted in the effect I was looking for. I actually just wrote that loop last night and thought I was soo smart! It didn't give me an error and I thought it was okay....well technically it does work....lol
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: get default button look back after changing button color

Post by Klaus »

Hint: That (default/empty property) is of course dependant on if and how this property
has been set in the next object in the hierarchie!

Example:
button -> group, if any -> card -> stack/mainstack if it is a substack - home stack (only in IDE) -> engine
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10502
Joined: Wed May 06, 2009 2:28 pm

Re: get default button look back after changing button color

Post by dunbarx »

There is a better way:

Early on:

set the defaultButtonProp of this card to the properties of button "yourButton"

Now fool around with it all you like.

Anytime you want to:

set the properties of btn 1 to the defaultButtonProp of this card

Craig
Post Reply