This is an example of another use for the OnStartup macros - to syncronize the state of any toggled buttons with the current state of any prefs they alter... in this case a button to toggle javascript on/off:
-------------------------------------------------------------------------------
OnStartup {
&buttonSync;
}
buttonSync {
getpref(BOOL, "javascript.enabled") ? pluginmsg(toolbars, "CheckButton", "Tool Bar, macros(jsToggle), 1") : pluginmsg(toolbars, "CheckButton", "Tool Bar, macros(jsToggle), 0");
}
# the above should be all one line!
jsToggle {
$tmp = (getpref(BOOL, "javascript.enabled") ? false : true);
setpref(BOOL, "javascript.enabled", $tmp);
statusbar("Java script " . ($tmp ? "enabled" : "disabled"));
&buttonSync;
}
----------------------------------------------------
and in toolbars.cfg, a button to fire the jsToggle macro:
JS {
macros(jsToggle)
Toggle Javascript
toolhot.bmp[11]
toolcold.bmp[11]
tooldead.bmp[11]
}
and k-meleon will now display the correct checked/unchecked state on the button when you start it up... yay! thanks for implementing this feature, developer folks.