It is currently April 19th, 2024, 4:55 am

Changing Shape Fill on Mouseover

Get help with creating, editing & fixing problems with skins
User avatar
andyblak
Posts: 12
Joined: May 16th, 2017, 12:09 pm

Changing Shape Fill on Mouseover

Post by andyblak »

Hey folks!

Just looking for some help with changing a meter's shape fill color on mouse over. I reviewed the !SetOption docs, but I'm not having much success. I am modifying the Enigma skin.

Here's my code snippet:

Code: Select all

[Variables]
BackgroundSoft=0,0,0,100
BackgroundFill=0,0,0,200

[MeterAllBackground]
Meter=Shape
Shape=Rectangle 1,1,197,170,12 | Fill Color #BackgroundSoft# | StrokeWidth 0.5 | Stroke Color #LabelColor#,150
W=199
H=124
UpdateDivider=-1
MouseOverAction=[!SetOption #CURRENTSECTION# Shape Fill Color #BackgroundFill#][!UpdateMeter #CURRENTSECTION#][!Redraw]
MouseLeaveAction=[!SetOption #CURRENTSECTION# Shape Fill Color #BackgroundSoft#][!UpdateMeter #CURRENTSECTION#][!Redraw]
Any help is appreciated!
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Changing Shape Fill on Mouseover

Post by balala »

The Shape option of the posted meter has more "subsequent" parts. The Fill Color is just one part of it. In such cases, to modify the meter, you have to modify the whole option. So, replace the MouseOverAction and MouseLeaveAction options with the following ones:

Code: Select all

[MeterAllBackground]
...
MouseOverAction=[!SetOption #CURRENTSECTION# Shape "Rectangle 1,1,197,170,12 | Fill Color #BackgroundFill# | StrokeWidth 0.5 | Stroke Color #LabelColor#,150"][!UpdateMeter "#CURRENTSECTION#"][!Redraw]
MouseLeaveAction=[!SetOption #CURRENTSECTION# Shape "Rectangle 1,1,197,170,12 | Fill Color #BackgroundSoft# | StrokeWidth 0.5 | Stroke Color #LabelColor#,150"][!UpdateMeter "#CURRENTSECTION#"][!Redraw]
Also be careful to include the value which will be set by the !SetOption bang, into quotes. Without them, especially if the value contains spaces, its setting won't work (and in this case, the values have spaces). But even if they don't have spaces, it's a good practice to become accustomed with usage of the quotes. Same about the !UpdateMeter (or any other) bang (I added those quotes above).
User avatar
andyblak
Posts: 12
Joined: May 16th, 2017, 12:09 pm

Re: Changing Shape Fill on Mouseover

Post by andyblak »

balala wrote:The Shape option of the posted meter has more "subsequent" parts. The Fill Color is just one part of it. In such cases, to modify the meter, you have to modify the whole option. So, replace the MouseOverAction and MouseLeaveAction options with the following ones:

Code: Select all

[MeterAllBackground]
...
MouseOverAction=[!SetOption #CURRENTSECTION# Shape "Rectangle 1,1,197,170,12 | Fill Color #BackgroundFill# | StrokeWidth 0.5 | Stroke Color #LabelColor#,150"][!UpdateMeter "#CURRENTSECTION#"][!Redraw]
MouseLeaveAction=[!SetOption #CURRENTSECTION# Shape "Rectangle 1,1,197,170,12 | Fill Color #BackgroundSoft# | StrokeWidth 0.5 | Stroke Color #LabelColor#,150"][!UpdateMeter "#CURRENTSECTION#"][!Redraw]
Also be careful to include the value which will be set by the !SetOption bang, into quotes. Without them, especially if the value contains spaces, its setting won't work (and in this case, the values have spaces). But even if they don't have spaces, it's a good practice to become accustomed with usage of the quotes. Same about the !UpdateMeter (or any other) bang (I added those quotes above).
Thank you very much for your help, balala! This resolved the issue.
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Changing Shape Fill on Mouseover

Post by balala »

andyblak wrote:Thank you very much for your help, balala! This resolved the issue.
I'm glad.
But there is one more approach, too.
According to this one, you should modify you code, to put the properties of the shape into different options, then modify just the needed one. For this you have to replace the Shape option of the [MeterAllBackground] meter, with the following one: Shape=Rectangle 1,1,197,170,12 | Extend MyModifier1, MyModifier2. See that here I replaced the fill and stroke properties with MyModifier1 and MyModifier2, which we have to define on the same Shape meter. To define them, add the following two options, to the [MeterAllBackground] meter:

Code: Select all

[MeterAllBackground]
...
MyModifier1=Fill Color #BackgroundSoft#
MyModifier2=StrokeWidth 0.5 | Stroke Color #LabelColor#,150
Now the only thing which must be updated when you're hovering the mouse over the meter, respectively when you're leaving it, is the MyModifier1 option. Replace the MouseOverAction and MouseLeaveAction options with the following ones:

Code: Select all

[MeterAllBackground]
...
MouseOverAction=[!SetOption #CURRENTSECTION# MyModifier1 "Fill Color #BackgroundFill#"][!UpdateMeter "#CURRENTSECTION#"][!Redraw]
MouseLeaveAction=[!SetOption #CURRENTSECTION# MyModifier1 "Fill Color #BackgroundSoft#"][!UpdateMeter "#CURRENTSECTION#"][!Redraw]
Maybe this approach can be a bit more understandable for many, being, I think, a bit more concise.
User avatar
andyblak
Posts: 12
Joined: May 16th, 2017, 12:09 pm

Re: Changing Shape Fill on Mouseover

Post by andyblak »

Very awesome! Thanks again for your help!
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Changing Shape Fill on Mouseover

Post by balala »

Glad to help.