Posted by: mhalsig
« on: September 20, 2020, 08:22:15 PM »I will give these suggestions a try. Thanks for your help.
_form toolbar1 {
p_backcolor=0x80000005;
p_border_style=BDS_SIZABLE;
p_caption="toolbar1";
p_CaptionClick=true;
p_forecolor=0x80000008;
p_height=476;
p_tool_window=true;
p_width=9954;
p_x=-16440;
p_y=3342;
p_eventtab2=_qtoolbar_etab2;
_image button2 {
p_auto_size=true;
p_backcolor=0x80000005;
p_border_style=BDS_NONE;
p_command="begin-line-text-toggle";
p_forecolor=0x80000008;
p_height=420;
p_max_click=MC_SINGLE;
p_message="Moves Cursor to the Beginning of the Current Line";
p_Nofstates=1;
p_picture="bbleft.svg";
p_stretch=false;
p_style=PSPIC_HIGHLIGHTED_BUTTON;
p_tab_index=1;
p_tab_stop=false;
p_value=0;
p_width=434;
p_x=140;
p_y=28;
p_eventtab2=_ul2_picture;
}
_image button1 {
p_auto_size=true;
p_backcolor=0x80000005;
p_border_style=BDS_NONE;
p_command="end-line-text-toggle";
p_forecolor=0x80000008;
p_height=420;
p_max_click=MC_SINGLE;
p_message="Moves Cursor to the Eeginning of the Current Line";
p_Nofstates=1;
p_picture="bbright.svg";
p_stretch=false;
p_style=PSPIC_HIGHLIGHTED_BUTTON;
p_tab_index=2;
p_tab_stop=false;
p_value=0;
p_width=434;
p_x=0;
p_y=0;
p_eventtab2=_ul2_picture;
}
}
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);
}
Is it possible to disable or hide a custom tool on a custom toolbar if an environment variable is not set?