I hope that this is a good place for a general js question. I've modified the samples/complete/playback buttons.js file to create a toolbar, and there are two toggling buttons on it that are related to one another. I would like to enable or disable the second of them depending on the state of the first.
The buttons themselves are defined thusly:
buttons.update = () => {
// other buttons omitted
buttons.buttons.editor = new _button(bs * 8, 0, bs, bs,
{normal : window.GetProperty('editorshown', fso.FileExists(filepath))
? bp + 'player_cool.png' : bp + 'editor_cool.png',
hover : window.GetProperty('editorshown') ? bp + 'player_hot.png'
: bp + 'editor_hot.png'},
(x, y) => { toggle_editor(); }, 'Editor/player');
buttons.buttons.showgroups = new _button(bs * 9, 0, bs, bs,
{normal : window.GetProperty('groupsshown')
? bp + 'grouphide_cool.png' : bp + 'groupshow_cool.png',
hover : window.GetProperty('groupsshown')
? bp + 'grouphide_hot.png' : bp + 'groupshow_hot.png'},
(x, y) => { toggle_groups(); }, 'Show/hide groups (editor)');
That toggle_editor function is as follows and is where I'd like to put the enabling/disabling of the showgroups button. At the moment, it toggles a window property to set the editor button's images and creates/deletes an empty file in order to tell a panel stack splitter to hide some elements and show others.
function toggle_editor() {
if (window.GetProperty('editorshown')) {
window.SetProperty('editorshown', false);
fso.DeleteFile(filepath);
} else {
window.SetProperty('editorshown', true);
fso.CreateTextFile(filepath).Close();
}
buttons.update();
window.Repaint();
}
So how can a javascript neophyte enable or disable a button like this? My searches turn up various ways of using javascript to interact with HTML buttons or what have you, but I can't tell if I've found anything dealing with a pure js setting. Would graphic actions like producing the "grayed out" effect happen automatically, or would I need to make another png for that?