It is currently March 9th, 2021, 10:19 am

[Bug] Can't use a nested variable as a bang?

Report bugs with the Rainmeter application and suggest features.
User avatar
Cariboudjan
Posts: 131
Joined: May 12th, 2019, 8:55 am

[Bug] Can't use a nested variable as a bang?

Post by Cariboudjan »

Left-clicking should perform the same function as right-clicking.

Code: Select all

[Rainmeter]

[Variables]
ButtonAction0=!ShowMeter
ButtonAction1=!HideMeter
ButtonActionNum=0

ButtonToggle=!ToggleMeter

[Meter1]
Meter=Image
SolidColor=255,55,55
W=50
H=50
LeftMouseUpAction=[!SetVariable ButtonActionNum (#ButtonActionNum#=0?1:0)][[#ButtonAction[#ButtonActionNum]] Meter2][!Update]
RightMouseUpAction=[!SetVariable ButtonActionNum (#ButtonActionNum#=0?1:0)][#ButtonToggle# Meter2][!Update]
DynamicVariables=1

[Meter2]
Meter=Image
SolidColor=255,255,55
Y=50
W=50
H=50
User avatar
Jeff
Posts: 190
Joined: September 3rd, 2018, 11:18 am

Re: [Bug] Can't use a nested variable as a bang?

Post by Jeff »

I really don't see anything wrong, as a workaround though, you can use a (undocumented) measure string as a bang

Code: Select all

LeftMouseUpAction=[!SetVariable ButtonActionNum "(#ButtonActionNum#=0?1:0)"][MeasureBang][!Update]
;...
[MeasureBang]
Measure=String
String=[&MeasureBang[#ButtonActionNum]] Meter2
DynamicVariables=1
[MeasureBang0]
Measure=String
String=!ShowMeter
[MeasureBang1]
Measure=String
String=!HideMeter
User avatar
Cariboudjan
Posts: 131
Joined: May 12th, 2019, 8:55 am

Re: [Bug] Can't use a nested variable as a bang?

Post by Cariboudjan »

Interesting that the bang would work as a measure but not as a variable?
User avatar
Jeff
Posts: 190
Joined: September 3rd, 2018, 11:18 am

Re: [Bug] Can't use a nested variable as a bang?

Post by Jeff »

Cariboudjan wrote: January 28th, 2021, 6:40 am Interesting that the bang would work as a measure but not as a variable?
It's a consequences of string variables or whatever this means
User avatar
Active Colors
Moderator
Posts: 663
Joined: February 16th, 2012, 3:32 am
Location: Berlin, Germany

Re: [Bug] Can't use a nested variable as a bang?

Post by Active Colors »

Code: Select all

[Variables]
ButtonAction0=!ShowMeter
ButtonAction1=!HideMeter
ButtonActionNum=0

Bangs with the section variables work a bit different. When you made a bang with section variables like this one:
LeftMouseUpAction=[[#ButtonAction[#ButtonActionNum]] Meter2]

you expected it be equal to this:
LeftMouseUpAction=[!ShowMeter Meter2]

but it does not work like this in such case. In fact, it is applied as if there are already brackets in your variable, so in your case it transforms the bang to this format:
LeftMouseUpAction=[[!ShowMeter] Meter2]

so the proper way would be having it this way :

Code: Select all

[Variables]
ButtonActionNum=0
ButtonAction0=!ShowMeter Meter2
ButtonAction1=!HideMeter Meter2

[Meter1]
LeftMouseUpAction=[#ButtonAction[#ButtonActionNum]] 
and it is going to work as LeftMouseUpAction=[!ShowMeter Meter2].
And for your case you can put it this way:

Code: Select all

[Variables]
ButtonActionNum=0
N=2
ButtonAction0=!ShowMeter Meter#N#
ButtonAction1=!HideMeter Meter#N#

[Meter1]
LeftMouseUpAction=[#ButtonAction[#ButtonActionNum]]
; you will need to have something like this:
LeftMouseUpAction=[!SetVariable N 2][#ButtonAction[#ButtonActionNum]]
User avatar
Jeff
Posts: 190
Joined: September 3rd, 2018, 11:18 am

Re: [Bug] Can't use a nested variable as a bang?

Post by Jeff »

1 brain is better than 2