Page 1 of 2
Inverting Buttons
Posted: Sun Jan 30, 2022 7:47 pm
by richmond62

- SShot 2022-01-30 at 20.45.18.png (3.64 KiB) Viewed 6097 times
-
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
Posted: Sun Jan 30, 2022 9:14 pm
by bn
Hi Richmond,
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
Kind regards
Bernd
Re: Inverting Buttons
Posted: Sun Jan 30, 2022 9:30 pm
by richmond62

- SShot 2022-01-30 at 22.28.35.png (6.39 KiB) Viewed 6076 times
-
Not really.
-
WARNING: this stack will muck up your interface.
Re: Inverting Buttons
Posted: Mon Jan 31, 2022 9:55 am
by stam
FerrusLogic recently posted an LC version of the JS tinyColor library - that probably will give you the colour alternatives you need…
Re: Inverting Buttons
Posted: Mon Jan 31, 2022 12:13 pm
by richmond62
FerrusLogic recently posted an LC version of the JS tinyColor library - that probably will give you the colour alternatives you need…
I know, and I have played around with it.
But I would like to know how to invert the colour of buttons . . .
Re: Inverting Buttons
Posted: Mon Jan 31, 2022 3:24 pm
by dunbarx
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
Re: Inverting Buttons
Posted: Mon Jan 31, 2022 3:52 pm
by richmond62
But I still do not understand what you are asking for.
"many a slip twixt cup abd lip"
I should like to make buttons like this:
-

- SShot 2022-01-31 at 16.50.05.png (3.03 KiB) Viewed 5915 times
-
Go like this:
-

- SShot 2022-01-31 at 16.50.05BTF.png (11.41 KiB) Viewed 5915 times
-
on a temporary basis.
Re: Inverting Buttons
Posted: Mon Jan 31, 2022 4:23 pm
by dunbarx
Richmond.
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
But you know this.
???
Craig
Re: Inverting Buttons
Posted: Mon Jan 31, 2022 5:24 pm
by richmond62
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.

Re: Inverting Buttons
Posted: Mon Jan 31, 2022 5:26 pm
by dunbarx
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
Re: Inverting Buttons
Posted: Mon Jan 31, 2022 5:29 pm
by richmond62
I bet that icons are drawn by the underlying OS
Neither in my example in the previous post nor in the "revmenuBar" stack:
-
Re: Inverting Buttons
Posted: Tue Feb 01, 2022 6:59 pm
by jacque
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.
Re: Inverting Buttons
Posted: Tue Feb 01, 2022 7:23 pm
by stam
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
Re: Inverting Buttons
Posted: Wed Feb 02, 2022 11:15 am
by richmond62
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.
Re: Inverting Buttons
Posted: Wed Feb 02, 2022 7:05 pm
by jacque
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:
Code: Select all
set the cUpColors of btn x to the properties of btn x
Now change the button to look like it's inverted state and:
Code: Select all
set the cDownColors of btn x to the properties of btn x
Now in a mouseDown handler:
Code: Select all
set the properties of btn x to the cDownColors of btn x
And the reverse on mouseUp and mouseRelease.