Command Group: GUI Control - Menu – Category

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "\{\{( *)Informative( *)\|" to "{{$1Feature$2|$2Informative$2|")
m (Some wiki formatting)
Line 3: Line 3:
'''Example for [[Eden Editor]]'''  
'''Example for [[Eden Editor]]'''  


{{cc|Create main folder}}
<sqf>
[[disableSerialization]];
// create main folder
[[private]] _ctrlMenuStrip = [[findDisplay]] 313 [[displayCtrl]] 120;
disableSerialization;
[[private]] _indexMain = _ctrlMenuStrip [[menuAdd]] [[], "Custom Tools"];
private _ctrlMenuStrip = findDisplay 313 displayCtrl 120;
 
private _indexMain = _ctrlMenuStrip menuAdd [[], "Custom Tools"];
{{cc|Create first subentry which is not checkable but has an action}}
[[private]] _indexUncheckable = _ctrlMenuStrip [[menuAdd]] [[_indexMain],"This entry can not be checked"];
// create first subentry which is not checkable but has an action
_ctrlMenuStrip [[menuSetAction]] [[_indexMain,_indexUncheckable], "[[systemChat]] 'Hello World!'"];
private _indexUncheckable = _ctrlMenuStrip menuAdd [[_indexMain], "This entry can not be checked"];
_ctrlMenuStrip menuSetAction [[_indexMain, _indexUncheckable], "systemChat 'Hello World!'"];


{{cc|Create second subentry which is checkable and has an action}}
// create second subentry which is checkable and has an action
[[private]] _indexCheckable = _ctrlMenuStrip [[menuAdd]] [[_indexMain],"This entry is checkable"];
private _indexCheckable = _ctrlMenuStrip menuAdd [[_indexMain], "This entry is checkable"];
_ctrlMenuStrip [[menuSetAction]] [[_indexMain,_indexCheckable], "[[systemChat]] 'Hello World!'"];
_ctrlMenuStrip menuSetAction [[_indexMain, _indexCheckable], "systemChat 'Hello World!'"];
_ctrlMenuStrip [[menuSetCheck]] [[_indexMain,_indexCheckable], true];
_ctrlMenuStrip menuSetCheck [[_indexMain, _indexCheckable], true];


{{cc|Create third subentry which shows an image and has an action}}
// create third subentry which shows an image and has an action
[[private]] _indexPicture = _ctrlMenuStrip [[menuAdd]] [[_indexMain],"This entry has a picture"];
private _indexPicture = _ctrlMenuStrip menuAdd [[_indexMain], "This entry has a picture"];
_ctrlMenuStrip [[menuSetAction]] [[_indexMain,_indexPicture], "[[systemChat]] 'Hello World!'"];
_ctrlMenuStrip menuSetAction [[_indexMain, _indexPicture], "systemChat 'Hello World!'"];
_ctrlMenuStrip [[menuSetPicture]] [[_indexMain,_indexPicture],"\a3\modules_f\data\iconunlock_ca.paa"];
_ctrlMenuStrip menuSetPicture [[_indexMain, _indexPicture], "\a3\modules_f\data\iconunlock_ca.paa"];


{{cc|Create a fourth entry which will destroy itself once clicked}}
// create a fourth entry which will destroy itself once clicked
[[private]] _indexDelete = _ctrlMenuStrip [[menuAdd]] [[_indexMain],"This entry will be deleted once clicked"];
private _indexDelete = _ctrlMenuStrip menuAdd [[_indexMain], "This entry will be deleted once clicked"];
_ctrlMenuStrip [[menuSetAction]] [[_indexMain,_indexDelete], "[[findDisplay]] 313 [[displayCtrl]] 120 [[menuDelete]] ([[menuHover]] ([[findDisplay]] 313 [[displayCtrl]] 120)); [[systemChat]] 'Entry gone!'"];
_ctrlMenuStrip menuSetAction [[_indexMain, _indexDelete], "findDisplay 313 displayCtrl 120 menuDelete (menuHover (findDisplay 313 displayCtrl 120)); systemChat 'Entry gone!'"];


{{cc|Create a fifth entry which will return its data once clicked}}
// create a fifth entry which will return its data once clicked
[[private]] _indexData = _ctrlMenuStrip [[menuAdd]] [[_indexMain],"This entry will print its data to system chat when clicked"];
private _indexData = _ctrlMenuStrip menuAdd [[_indexMain], "This entry will print its data to system chat when clicked"];
_ctrlMenuStrip [[menuSetData]] [[_indexMain,_indexData], "<nowiki>[</nowiki>[[objNull]],'Some String',[[true]]]"];
_ctrlMenuStrip menuSetData [[_indexMain, _indexData], "<nowiki>[</nowiki>objNull,'Some String',true]"];
_ctrlMenuStrip [[menuSetAction]] [[_indexMain,_indexData], "[[systemChat]] ([[findDisplay]] 313 [[displayCtrl]] 120 [[menuData]] ([[menuHover]] ([[findDisplay]] 313 [[displayCtrl]] 120)));"];
_ctrlMenuStrip menuSetAction [[_indexMain, _indexData], "systemChat (findDisplay 313 displayCtrl 120 menuData (menuHover (findDisplay 313 displayCtrl 120)));"];
</sqf>
 
{{Feature|informative|To remove the custom menu, just restart [[:Category:Eden Editor|Eden Editor]].}}


{{Feature|Informative|To remove the custom menu, just restart [[Eden Editor]].}}


[[Category:Command Group: GUI Control]]
[[Category:Command Group: GUI Control]]

Revision as of 14:52, 24 March 2023

Commands to manipulate CT_MENU_STRIP, CT_MENU, CT_CONTEXT_MENU controls. CT_MENU_STRIP and CT_CONTEXT_MENU were introduced with Eden Editor. See Entity Context Menu and Configuring Menu Bar to find out how to configure these menus in Eden Editor.

Example for Eden Editor

// create main folder disableSerialization; private _ctrlMenuStrip = findDisplay 313 displayCtrl 120; private _indexMain = _ctrlMenuStrip menuAdd [[], "Custom Tools"]; // create first subentry which is not checkable but has an action private _indexUncheckable = _ctrlMenuStrip menuAdd [[_indexMain], "This entry can not be checked"]; _ctrlMenuStrip menuSetAction [[_indexMain, _indexUncheckable], "systemChat 'Hello World!'"]; // create second subentry which is checkable and has an action private _indexCheckable = _ctrlMenuStrip menuAdd [[_indexMain], "This entry is checkable"]; _ctrlMenuStrip menuSetAction [[_indexMain, _indexCheckable], "systemChat 'Hello World!'"]; _ctrlMenuStrip menuSetCheck [[_indexMain, _indexCheckable], true]; // create third subentry which shows an image and has an action private _indexPicture = _ctrlMenuStrip menuAdd [[_indexMain], "This entry has a picture"]; _ctrlMenuStrip menuSetAction [[_indexMain, _indexPicture], "systemChat 'Hello World!'"]; _ctrlMenuStrip menuSetPicture [[_indexMain, _indexPicture], "\a3\modules_f\data\iconunlock_ca.paa"]; // create a fourth entry which will destroy itself once clicked private _indexDelete = _ctrlMenuStrip menuAdd [[_indexMain], "This entry will be deleted once clicked"]; _ctrlMenuStrip menuSetAction [[_indexMain, _indexDelete], "findDisplay 313 displayCtrl 120 menuDelete (menuHover (findDisplay 313 displayCtrl 120)); systemChat 'Entry gone!'"]; // create a fifth entry which will return its data once clicked private _indexData = _ctrlMenuStrip menuAdd [[_indexMain], "This entry will print its data to system chat when clicked"]; _ctrlMenuStrip menuSetData [[_indexMain, _indexData], "<nowiki>[</nowiki>objNull,'Some String',true]"]; _ctrlMenuStrip menuSetAction [[_indexMain, _indexData], "systemChat (findDisplay 313 displayCtrl 120 menuData (menuHover (findDisplay 313 displayCtrl 120)));"];

To remove the custom menu, just restart Eden Editor.