Inverting Buttons
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Livecode Opensource Backer
- Posts: 10098
- Joined: Fri Feb 19, 2010 10:17 am
Inverting Buttons
I would like to invert the colour of a button . . . so that any thing behind it does NOT show through.
I have played around with inks, backGroundColor and foreGroundColor to no avail.
Re: Inverting Buttons
Hi Richmond,
does this do what you want when you put this script into the button?
Kind regards
Bernd
does this do what you want when you put this script into the button?
Code: Select all
local sBGColor, sFGColor
on mouseDown
lock screen
put the effective backgroundcolor of me into sBGColor
put sBGColor into tBGColor
repeat with i = 1 to 3
put 255 - item i of tBGColor into item i of tBGColor
end repeat
set the hiliteColor of me to tBGColor
put the effective foregroundColor of me into sFGColor
put sFGColor into tFGColor
repeat with i = 1 to 3
put 255 - item i of tFGColor into item i of tFGColor
end repeat
set the foregroundColor of me to tFGColor
end mouseDown
on mouseUp
lock screen
set the backgroundColor of me to sBGColor
set the foregroundColor of me to sFGColor
end mouseUp
Bernd
-
- Livecode Opensource Backer
- Posts: 10098
- Joined: Fri Feb 19, 2010 10:17 am
Re: Inverting Buttons
Not really.
-
WARNING: this stack will muck up your interface.
- Attachments
-
- Strike Me Pink.livecode.zip
- Here's the stack.
- (2.59 KiB) Downloaded 123 times
Re: Inverting Buttons
FerrusLogic recently posted an LC version of the JS tinyColor library - that probably will give you the colour alternatives you need…
-
- Livecode Opensource Backer
- Posts: 10098
- Joined: Fri Feb 19, 2010 10:17 am
Re: Inverting Buttons
I know, and I have played around with it.FerrusLogic recently posted an LC version of the JS tinyColor library - that probably will give you the colour alternatives you need…
But I would like to know how to invert the colour of buttons . . .
Re: Inverting Buttons
Richmond.
I have your stack, which changes the color of the revmenubar. What has that got to do with buttons?
But I still do not understand what you are asking for. Controls behind an opaque button do not "show through" in any case. And what does "invert the color" mean?
Craig
I have your stack, which changes the color of the revmenubar. What has that got to do with buttons?
But I still do not understand what you are asking for. Controls behind an opaque button do not "show through" in any case. And what does "invert the color" mean?
Craig
-
- Livecode Opensource Backer
- Posts: 10098
- Joined: Fri Feb 19, 2010 10:17 am
Re: Inverting Buttons
"many a slip twixt cup abd lip"But I still do not understand what you are asking for.
I should like to make buttons like this:
- -
Go like this:
- -
on a temporary basis.
Re: Inverting Buttons
Richmond.
So let us say you have a button with something like this in its script:
But you know this.
???
Craig
So let us say you have a button with something like this in its script:
Code: Select all
on mouseUp
if the backColor of me = "" then set the backColor of me to "yellow" else set the backColor of me to ""
end mouseUp
???
Craig
-
- Livecode Opensource Backer
- Posts: 10098
- Joined: Fri Feb 19, 2010 10:17 am
Re: Inverting Buttons
The problem re a backColor is that that will not invert the colour of an icon in a button.
And if the ink of the source image (for the icon) is set to blendExclusion, as soon
as one modifies the backColor the image displays inwith the button as srcCopy:
- -
No dice.
And if the ink of the source image (for the icon) is set to blendExclusion, as soon
as one modifies the backColor the image displays inwith the button as srcCopy:
- -
No dice.

Re: Inverting Buttons
Aha.
Invert the ICON. Why didn't you say so?
I bet that icons are drawn by the underlying OS, so you cannot futz with them. Others may tell me I am wrong...
Craig
Invert the ICON. Why didn't you say so?
I bet that icons are drawn by the underlying OS, so you cannot futz with them. Others may tell me I am wrong...
Craig
-
- Livecode Opensource Backer
- Posts: 10098
- Joined: Fri Feb 19, 2010 10:17 am
Re: Inverting Buttons
Neither in my example in the previous post nor in the "revmenuBar" stack:I bet that icons are drawn by the underlying OS
-
Re: Inverting Buttons
If you want to change the appearance of the icon, you need to alter the source image. Changing the button itself won't do it, though you might be able to get away with setting a color overlay in the special effects pane of the property inspector.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Inverting Buttons
One way around this may be to use the Universal Button widget, which allows you to set different icons for normal and hilited states (so, less coding...), plus set colours as you'd expect from a normal button...
https://github.com/revig/universal-button-widget
https://github.com/revig/universal-button-widget
-
- Livecode Opensource Backer
- Posts: 10098
- Joined: Fri Feb 19, 2010 10:17 am
Re: Inverting Buttons
Indeed, Jacque and Stam both; and thank you for your suggestions.
However I should like to alter the colours of buttons and their icons in a
NON-DESTRUCTIVE fashion, so that "with the flick of a switch" on could
flip back and forth between 2 colour states.
And, when push comes to shove, all I am really looking
for is a way to INVERT all colours of an object.
However I should like to alter the colours of buttons and their icons in a
NON-DESTRUCTIVE fashion, so that "with the flick of a switch" on could
flip back and forth between 2 colour states.
And, when push comes to shove, all I am really looking
for is a way to INVERT all colours of an object.
Re: Inverting Buttons
If none of the inks work as desired you'll need to code it. Set up the button in its unaltered state and store its properties in a custom property:
Now change the button to look like it's inverted state and:
Now in a mouseDown handler:
And the reverse on mouseUp and mouseRelease.
Code: Select all
set the cUpColors of btn x to the properties of btn x
Code: Select all
set the cDownColors of btn x to the properties of btn x
Code: Select all
set the properties of btn x to the cDownColors of btn x
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com