UpdateButtons - A script command for updating all button-icons and toggle-states to reflect values in global/local variables.
The script below is probably obsolete, please read on:
The method Command.UpdateToggle() seems to have an effect on refreshing icons as well, not just on the toggle state.
So a very simple usercommand seems to do the job quite nicely (to be able to update buttons by dopusrt.exe from an external application e.g.).
<?xml version="1.0"?>
<button backcol="none" display="icon" textcol="none">
<label>UpdateButtons2</label>
<tip>Update all button icons and toggle states</tip>
<icon1>#usercommand</icon1>
<function type="script">
<instruction>@script jscript</instruction>
<instruction>function OnClick(data){</instruction>
<instruction> var cmd = DOpus.NewCommand();</instruction>
<instruction> cmd.UpdateToggle();</instruction>
<instruction>}</instruction>
</function>
</button>
(Note: Adding @toggle:update to a normal, non-script command should also achieve the same thing, without the need for any script or user command, at least in theory. I'm not sure if that existed at the time this was written. --Leo)
The downloadable script maybe still be useful as an example on how to find specific toolbars or how to handle them in scripting.
Description:
I found out that toggling a toolbar by script or button helps to make icons and toggle-states update, so I did this.
Normally buttons are updated only right after switching tabs or between listers, so this allows to run any command and forcing
a button refresh at the same time. It updates all buttons in every open lister. This is experimental so your mileage may vary. o)
Parameters:
none
Usage:
Just call "UpdateButtons" from a button/hotkey or script. You should have some buttons making use of variables to change
their icon and "pressed" appearance. If you just want to try, use code like this to test for a variable "Script.UpdateButtons.Test".
<?xml version="1.0"?>
<button backcol="none" display="both" textcol="none">
<label>UpdateButtons-Test</label>
<icon1>#newcommand</icon1>
<function type="normal">
<instruction>@toggle:if $glob:Script.UpdateButtons.Test</instruction>
<instruction>@icon:importexport,$glob:Script.UpdateButtons.Test</instruction>
</function>
</button>
Installation:
To install the command, download the *.js.txt file below and drag it to Preferences / Toolbars / Scripts.
Download:
-
Latest: v0.2 - working version, but obsolete:
Command.GUI_UpdateButtons.js.txt (2.83 KB) -
v0.1 - initial version:
Command.GUI_UpdateButtons.js.txt (1.43 KB)