It is currently May 3rd, 2024, 9:01 am
Toggle Buttons
-
- Posts: 1
- Joined: July 15th, 2014, 4:28 pm
Toggle Buttons
-snip-
Last edited by liljohn360 on January 12th, 2017, 5:35 pm, edited 1 time in total.
-
- Developer
- Posts: 22631
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Toggle Buttons
http://rainmeter.net/forum/viewtopic.php?p=90054#p90054
Pretty straightforward. If ToggleVar is 0, then 1-0 = 1. If ToggleVar is 1, then 1-1 = 0.
You can use !WriteKeyValue in addition to !SetVariable if you want the change to be permanent.
Note that while multiple bangs take place one after the other, and in other cases a change made in one bang would impact what is seen by a second bang, the exception is that all #VarName# and [Section] variables in an option are evaluated and populated with their values all at once when the action option is read. That is why we repeat the formula both in !SetVariable and !WriteKeyValue.
You can use !SetOption instead of !SetVariable if you want to use a Calc measure to control things instead of a #VarName#. This has the advantage of allowing IfCondition or IfAction options on the Calc measure to take some action(s) when the toggled value changes. (maybe turning on or off Aero Blur if you really want that)
Code: Select all
[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1
[Variables]
ToggleVar=0
[MeterToggle]
Meter=String
FontSize=13
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=ToggleVar = #ToggleVar#
DynamicVariables=1
LeftMouseUpAction=[!SetVariable ToggleVar (1-#ToggleVar#)][!UpdateMeter *][!Redraw]
You can use !WriteKeyValue in addition to !SetVariable if you want the change to be permanent.
Code: Select all
LeftMouseUpAction=[!SetVariable ToggleVar (1-#ToggleVar#)][!WriteKeyValue Variables ToggleVar (1-#ToggleVar#)][!UpdateMeter *][!Redraw]
You can use !SetOption instead of !SetVariable if you want to use a Calc measure to control things instead of a #VarName#. This has the advantage of allowing IfCondition or IfAction options on the Calc measure to take some action(s) when the toggled value changes. (maybe turning on or off Aero Blur if you really want that)
Code: Select all
[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1
[MeasureToggle]
Measure=Calc
Formula=0
UpdateDivider=-1
IfCondition=MeasureToggle = 0
IfTrueAction=[!SetOption MeterToggle FontColor "148,247,153,255"][!UpdateMeter *][!Redraw]
IfFalseAction=[!SetOption MeterToggle FontColor "247,228,148,255"][!UpdateMeter *][!Redraw]
[MeterToggle]
Meter=String
MeasureName=MeasureToggle
FontSize=13
FontColor=150,150,150,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=ToggleVar = %1
DynamicVariables=1
LeftMouseUpAction=[!SetOption MeasureToggle Formula (1-[MeasureToggle])][!WriteKeyValue MeasureToggle Formula (1-[MeasureToggle])][!UpdateMeasure MeasureToggle]
You do not have the required permissions to view the files attached to this post.