ok, so it looks like you can't give a name to any of the buttons on a custom toolbar. From digging through the help I found that it says you can provide a callback (OnUpdate) to enable or disable a "menu item" - but it might work for a toolbar button too.
If you right click on one of your toolbar buttons and select properties, then click the "auto enable" you get the auto enable properties dialog. In the help, if you search for "Toolbar Control Properties Dialog" you'll see it links to "Auto Enable Properties Dialog". If you search for "Macro Callbacks for Enabling Commands" you'll see the stuff below.
If that doesn't work you can wrap the command that the button calls with another command that checks the environment variable before calling the actual command. If that doesn't help you could create a form with named buttons - but I don't know how to make it behave like a toolbar.
If the auto-enable attributes do not provide the features that you want, you can define the enable and
disable callback for the command. The name of the callback function you define is based on the name of
the command as shown in the following example:
#include "slick.sh"
static bool gSomeOtherState;
/*
This function gets called if your command is used in a menu or
toolbar.
You must return a combination of the MF_ flags ORed together.
BEWARE: If an _OnUpdate callback causes a Slick-C run-time error,
you
may not see the error. In addition, the timer used for toolbars,
Context Tagging(R), AutoSave, and some other features may be
automatically terminated. Exit and restart the editor to restart
this timer. Use the "say" function to debug your _OnUpdate
callback.
*/
int _OnUpdate_mycommand(CMDUI &cmdui,int target_wid,_str command)
{
//say('h1');
// Lets assume this command requires the target to be an editor
control
// with a selection.
// IF the target is not an editor control:
if ( !target_wid || !target_wid._isEditorCtl()) {
//say('disabled at h2');
return(MF_GRAYED);
}
//say('h3');
// IF the editor control does not have a selection:
if (!target_wid.select_active2()) {
//say('disabled at h4');
return(MF_GRAYED);
}
//say('h5');
Creating and Editing Menu
Resources
1457if (gSomeOtherState) {
//say('disabled at h6');
return(MF_GRAYED);
}
//say('enabled at h7')
return(MF_ENABLED);
}
_command void mycommand() name_info(','VSARG2_REQUIRES_EDITORCTL)
{
// Some code here...
}
// This command affects the enable/disable of mycommand.
_command void mycommand2(_str argument="0")
{
gSomeOtherState=(argument)?1:0;
// Indicate that the enable state of the toolbar buttons must be
updated.
// The _tbSetRefreshBy function is very fast. Toolbars will be
updated
// after the macro terminates and the user stops typing fast.
_tbSetRefreshBy(VSTBREFRESHBY_USER);
}