It is currently March 28th, 2024, 11:27 pm

OnRefreshAction

Discussions about the documentation, main Rainmeter site and forums.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: OnRefreshAction

Post by jsmorley »

No, really nothing at all happens twice.

If you use this skin:

Code: Select all

[Rainmeter]
Update=5000
OnRefreshAction=[!SetOption MeterOne Text "After OnRefresh"][!Log "Just Refreshed"]

[MeterOne]
Meter=String
FontSize=11
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=Before OnRefresh
You will get "Before OnRefresh" for 5 seconds, then when the meter is updated and the skin is redrawn during the second update, it will change to "After OnRefresh". There will be one and only one "Just Refreshed" in the log.

Why? Because the !SetOption happens after the meter is updated and the skin is "drawn" on the screen during the first update. The meter will be updated and the skin drawn again (reflected the changed value) during the second update cycle.

If you use this skin:

Code: Select all

[Rainmeter]
Update=5000
OnRefreshAction=[!SetOption MeterOne Text "After OnRefresh"][!Log "Just Refreshed"][!UpdateMeter *][!Redraw]

[MeterOne]
Meter=String
FontSize=11
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=Before OnRefresh
You will simply get "After Refresh" and one and only one "Just Refreshed" in the log.

Why? Because all the above is still true, but you are forcing an extra update to the meter and an extra redraw of the skin at the end of the first update cycle, before it starts waiting Update=5000 (5 seconds) for the next cycle.

As I said, the long and the short of it is that when a skin is loaded or refreshed it does:

Update measures
Update meters
Draw skin
Execute OnRefreshAction

followed by an endless loop of:

Wait Update millisconds
Update measures
Update meters
Draw skin

Nothing more, nothing less...

I think the key to this is already pretty clear in the documentation. OnRefreshAction happens LAST in the first update cycle when a skin is first loaded or refreshed, and the fact that it is near the top of the skin has nothing whatever to do with when it is run. It is the very last thing the skin does before it starts waiting Update milliseconds for the next update cycle. I do think the fact that it happens even after the skin is "drawn" at the end of the first update cycle could be more clear. I will look into making a change to that.