It is currently April 28th, 2024, 12:02 pm

Problem with !SetOption bang (not sure if bug or not)

Get help with creating, editing & fixing problems with skins
User avatar
haibusa2005
Posts: 52
Joined: June 15th, 2011, 7:23 pm
Location: Bulgaria, Varna

Problem with !SetOption bang (not sure if bug or not)

Post by haibusa2005 »

So I am controlling the opacity of the meter with a fade timer but I also need the color of the faded string to change on mouse hover. I made a simplified version of the meter but the problem still persists. So basically if I just set the OpMain variable to 255 and 0 without hovering the string, everything is OK, works as many times as I click the buttons. If I hover the string while OpMain=255 the text brightens and darkens as expected. If I set OpMain=0, the text should disappear since it's fully transparent. But it doesn't! Color is dim and of hover over it disappears. If I set OpMain=255 again the text doesn't even become opaque. On the full version skin I have a click field that handles the matter and the text becomes visible once I hover the field but the string itself must be already visible. Here is the simplified code

EDIT: I forgot to mention - Windows 7 Ultimate x64, Rainmeter 2.4 r1578

Code: Select all

[Rainmeter]
Author=Haibusa2005
Update=1000
MiddleMouseDownAction=[!Refresh]

[Variables]
OpMain=0
ColorDimP=160,160,160
ColorBrightP=255,255,255

[ButtonIn]
Meter=Image
SolidColor=255,0,0,255
x=0
y=0
h=20
w=20
LeftMouseUpAction=[!SetVariable OpMain 255] [!UpdateMeter StringExtra] [!Redraw]
TooltipText=Toggle opaque

[ButtonOut]
Meter=Image
SolidColor=0,255,0,255
x=30
y=0
h=20
w=20
LeftMouseUpAction=[!SetVariable OpMain 0] [!UpdateMeter StringExtra] [!Redraw]
TooltipText=Toggle invisible

[StringExtra]
DynamicVariables=1
Meter=String
x=0
y=30
FontColor="#ColorDimP#,#OpMain#"
FontSize=16
Text="qwerty"
MouseOverAction=[!SetOption StringExtra FontColor "#ColorBrightP#,#OpMain#"] [!UpdateMeter StringExtra] [!Redraw]
MouseLeaveAction=[!SetOption StringExtra FontColor "#ColorDimP#,#OpMain#"] [!UpdateMeter StringExtra] [!Redraw]
User avatar
Kaelri
Developer
Posts: 1721
Joined: July 25th, 2009, 4:47 am

Re: Problem with !SetOption bang (not sure if bug or not)

Post by Kaelri »

When setting the new FontColor option, you need to "escape" the OpMain variable.

Code: Select all

MouseOverAction=[!SetOption StringExtra FontColor "#ColorBrightP#,#*OpMain*#"][!UpdateMeter StringExtra][!Redraw]
MouseLeaveAction=[!SetOption StringExtra FontColor "#ColorDimP#,#*OpMain*#"][!UpdateMeter StringExtra][!Redraw]
Otherwise, you're replacing the variable reference (#OpMain#) with the literal value of #OpMain# at whatever time the bang is sent, and the meter will no longer react when the variable changes. With escape characters, #OpMain# is not parsed, but instead written as is.
User avatar
haibusa2005
Posts: 52
Joined: June 15th, 2011, 7:23 pm
Location: Bulgaria, Varna

Re: Problem with !SetOption bang (not sure if bug or not)

Post by haibusa2005 »

That did the job. This is some pretty dark rainmeter magic, thank you for enlightening me, Kaelri :) I guess I should read the entire manual some day...
User avatar
Kaelri
Developer
Posts: 1721
Joined: July 25th, 2009, 4:47 am

Re: Problem with !SetOption bang (not sure if bug or not)

Post by Kaelri »

Just steer clear of ritual goat sacrifice, and you should be ok. :)