Simple disable button in script

Hello!
How can I simple disable/enable a menubutton in another script of button?
There is no condition or environment status.
Thanks!

What kind of menu button? One in a normal Opus toolbar? Or do you mean a button in a script dialog?

I want to disable or enable a normal main menu button in another main menu button script.
For example:
image

You can use @toggle and variables to do that.

See Command modifier reference around this part:

The @toggle directive can also test for the existence of a variable (one set via the @set directive) ...

Thanks.
Unfortunately, I don't quite understand yet.
For example, let it:
Btn1 is the button I want to disable / enable.
Btn2 to disable Btn1.
Btn3 to enable Btn1.
What should I write in the Btn2 and Btn3 button script?

Are Btn2 and Btn3 actual scripts (as in VBScript or JScript), or are they just normal buttons?

You can do it in both, but the best/exact way you do it is different.

Scripts are VBScript.

Button (not a script):

@disableif:$glob:DisableMyButton
// ...

Disable the button (VBScript):

Option Explicit
Function OnClick(ByRef clickData)
	Dim cmd, globals
	Set cmd = clickData.func.command
	Set globals = DOpus.Vars
	
	globals.Set "DisableMyButton", TRUE
	cmd.UpdateToggle
End Function

Enable the button (VBScript):

Option Explicit
Function OnClick(ByRef clickData)
	Dim cmd, globals
	Set cmd = clickData.func.command
	Set globals = DOpus.Vars
	
	globals.Delete "DisableMyButton"
	cmd.UpdateToggle
End Function

.DCF files for all the above: Buttons.7z (646 Bytes)

1 Like

Thank you very much, I will try ...

That's great!
It works.
Thanks

1 Like