ctrlCreate: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "\[\[Category\: ?Command[ _]Group\:.*\|\{\{uc\:\{\{PAGENAME\}\}\}\}\]\] " to "")
m (updated description)
Line 10: Line 10:


| Creates a new control in the given display. The control class could be existing class from [[configFile | main config]] or custom class defined in [[missionConfigFile | mission config]] (main config is searched first, if no such class exists, mission config is searched). Some of the common controls defined in main config that can be used with this command:
| Creates a new control in the given display. The control class could be existing class from [[configFile | main config]] or custom class defined in [[missionConfigFile | mission config]] (main config is searched first, if no such class exists, mission config is searched). Some of the common controls defined in main config that can be used with this command:
* <tt>RscText</tt> - simple text box
 
* <tt>RscStructuredText</tt> - text box which supports [[Structured Text|structured text]]
{{{!}} class{{=}}"wikitable" width {{=}} "100%"
* <tt>RscTextMulti</tt> - simple multiline text box
{{!}}-
* <tt>RscPicture</tt> - simple picture box
! Class !! Description !! Available since
* <tt>RscPictureKeepAspect</tt> - picture box that doesn't stretch picture
{{!}}-
* <tt>RscEdit</tt> - input box
{{!}} RscText {{!}}{{!}} simple text box {{!}}{{!}}
* <tt>RscEditMulti</tt> - multiline input box
{{!}}-
* <tt>RscEditReadOnly</tt> - input box with [[DialogControls-EditBox | <tt>canModify {{=}} false;</tt>]] (since v1.97)
{{!}} RscStructuredText {{!}}{{!}} text box which supports [[Structured Text|structured text]] {{!}}{{!}}
* <tt>RscEditMultiReadOnly</tt> - multiline input box with [[DialogControls-EditBox | <tt>canModify {{=}} false;</tt>]] (since v1.97)
{{!}}-
* <tt>RscTree</tt> - tree view control
{{!}} RscTextMulti {{!}}{{!}} simple multiline text box {{!}}{{!}}
* <tt>RscTreeMulti</tt> - multi-select tree view (since v2.01)
{{!}}-
* <tt>RscTreeSearch</tt> - searchable tree view control (see Example 4)
{{!}} RscPicture {{!}}{{!}} simple picture box {{!}}{{!}}
* <tt>RscVideo</tt> - picture control with autostart for video texture (see [[BIS_fnc_playVideo]])
{{!}}-
* <tt>RscVideoKeepAspect</tt> - picture control for video to keep original video aspect ratio
{{!}} RscPictureKeepAspect {{!}}{{!}} picture box that doesn't stretch picture {{!}}{{!}}
* <tt>RscButtonMenuBIKI</tt> - shortcut button with url pointing to "https://community.bistudio.com/wiki/" (since v1.97)
{{!}}-
* <tt>RscControlsGroup</tt> - default controls group
{{!}} RscEdit {{!}}{{!}} input box {{!}}{{!}}
* <tt>RscControlsGroupNoScrollbars</tt> - controls group without scrollbars
{{!}}-
* <tt>RscControlsGroupNoHScrollbars</tt> - controls group without horizontal scrollbar
{{!}} RscEditMulti {{!}}{{!}} multiline input box {{!}}{{!}}
* <tt>RscControlsGroupNoVScrollbars</tt> - controls group without vertical scrollbar|DESCRIPTION=
{{!}}-
{{!}} RscEditReadOnly {{!}}{{!}} input box with [[DialogControls-EditBox | <tt>canModify {{=}} false;</tt>]] {{!}}{{!}} since v1.97
{{!}}-
{{!}} RscEditMultiReadOnly {{!}}{{!}} multiline input box with [[DialogControls-EditBox | <tt>canModify {{=}} false;</tt>]]{{!}}{{!}} since v1.97
{{!}}-
{{!}} RscTree {{!}}{{!}} tree view control {{!}}{{!}}
{{!}}-
{{!}} RscTreeMulti {{!}}{{!}} multi-select tree view {{!}}{{!}} v2.01
{{!}}-
{{!}} RscTreeSearch {{!}}{{!}} searchable tree view control (see Example 4) {{!}}{{!}}
{{!}}-
{{!}} RscVideo {{!}}{{!}} picture control with autostart for video texture (see [[BIS_fnc_playVideo]]) {{!}}{{!}}
{{!}}-
{{!}} RscVideoKeepAspect {{!}}{{!}} picture control for video to keep original video aspect ratio {{!}}{{!}}
{{!}}-
{{!}} RscButtonMenuBIKI {{!}}{{!}} shortcut button with url pointing to "https://community.bistudio.com/wiki/" {{!}}{{!}} v1.97
{{!}}-
{{!}} RscControlsGroup {{!}}{{!}} default controls group {{!}}{{!}}
{{!}}-
{{!}} RscControlsGroupNoScrollbars {{!}}{{!}} controls group without scrollbars {{!}}{{!}}
{{!}}-
{{!}} RscControlsGroupNoHScrollbars {{!}}{{!}} controls group without horizontal scrollbar {{!}}{{!}}
{{!}}-
{{!}} RscControlsGroupNoVScrollbars {{!}}{{!}} controls group without vertical scrollbar {{!}}{{!}}
{{!}}-
{{!}}}|DESCRIPTION=
____________________________________________________________________________________________
____________________________________________________________________________________________



Revision as of 01:08, 5 October 2020

Hover & click on the images for description

Description

Description:
Creates a new control in the given display. The control class could be existing class from main config or custom class defined in mission config (main config is searched first, if no such class exists, mission config is searched). Some of the common controls defined in main config that can be used with this command:
Class Description Available since
RscText simple text box
RscStructuredText text box which supports structured text
RscTextMulti simple multiline text box
RscPicture simple picture box
RscPictureKeepAspect picture box that doesn't stretch picture
RscEdit input box
RscEditMulti multiline input box
RscEditReadOnly input box with canModify = false; since v1.97
RscEditMultiReadOnly multiline input box with canModify = false; since v1.97
RscTree tree view control
RscTreeMulti multi-select tree view v2.01
RscTreeSearch searchable tree view control (see Example 4)
RscVideo picture control with autostart for video texture (see BIS_fnc_playVideo)
RscVideoKeepAspect picture control for video to keep original video aspect ratio
RscButtonMenuBIKI shortcut button with url pointing to "https://community.bistudio.com/wiki/" v1.97
RscControlsGroup default controls group
RscControlsGroupNoScrollbars controls group without scrollbars
RscControlsGroupNoHScrollbars controls group without horizontal scrollbar
RscControlsGroupNoVScrollbars controls group without vertical scrollbar
Groups:
GUI Control

Syntax

Syntax:
display ctrlCreate [class, idc, controlsGroup]
Parameters:
display: Display - Display in which control will be created
[class, idc, controlsGroup]: Array
class: String - Existing classname (see ctrlCreate/classnames) of the new control (Since Arma 3 v1.69.141213 it is possible to use classes defined in mission config)
idc: Number - IDC of the new control (use -1 if you don't care what it should be)
controlsGroup (Optional): Control - Creates controls in existing controls group
Return Value:
Control

Examples

Example 1:
_display ctrlCreate ["RscText", 1234];
Example 2:
_map = findDisplay 46 ctrlCreate ["RscMapControl", -1]; _multiLineText = findDisplay 46 ctrlCreate ["RscTextMulti", -1]; _multiLineEdit = findDisplay 46 ctrlCreate ["RscEditMulti", -1];
Example 3:
myControl = findDisplay 0 ctrlCreate ["RscText", 1234, findDisplay 0 displayCtrl 2300];
Example 4:
Create Tree View control with search. Available RscTreeSearch class is hardcoded to be used with RscEdit with idc 645. Example below demonstrates how to. After tree is generated, try typing something in the top box. [] spawn { disableSerialization; _display = findDisplay 46 createDisplay "RscDisplayEmpty"; _edit = _display ctrlCreate ["RscEdit", 645]; _edit ctrlSetPosition [0,0,1,0.04]; _edit ctrlSetBackgroundColor [0,0,0,1]; _edit ctrlCommit 0; _tv = _display ctrlCreate ["RscTreeSearch", -1]; _tv ctrlSetFont "EtelkaMonospacePro"; _tv ctrlSetFontHeight 0.03; _tv ctrlSetPosition [0,0.06,1,0.94]; _tv ctrlSetBackgroundColor [0,0,0,1]; _tv ctrlCommit 0; _classes = "true" configClasses (configFile >> "CfgVehicles"); for "_i" from 0 to 5 do { _tv tvAdd [[], configName selectRandom _classes]; for "_j" from 0 to 5 do { _tv tvAdd [[_i], configName selectRandom _classes]; for "_k" from 0 to 5 do { _tv tvAdd [[_i, _j], configName selectRandom _classes]; for "_n" from 0 to 5 do { _tv tvAdd [[_i, _j, _k], configName selectRandom _classes]; }; }; }; }; };
This TreeView search built in mechanics is very slow for some reason, you would probably be better off redrawing the whole list each time.
Example 5:
Create a simple submit edit box and show content in hint: disableSerialization;

private _display = findDisplay 46 createDisplay "RscDisplayEmpty"; private _ctrlGroup = _display ctrlCreate ["RscControlsGroupNoScrollbars", -1]; private _ctrlBackground = _display ctrlCreate ["RscTextMulti", -1, _ctrlGroup]; IDD_EDIT_BOX = 123; private _ctrlEdit = _display ctrlCreate ["RscEditMulti", IDD_EDIT_BOX, _ctrlGroup]; private _ctrlButton = _display ctrlCreate ["RscShortcutButton", -1, _ctrlGroup]; _ctrlGroup ctrlSetPosition [0.5, 0.5, 0, 0]; _ctrlGroup ctrlCommit 0; _ctrlBackground ctrlSetPosition [0, 0, 0.5, 0.5]; _ctrlBackground ctrlSetBackgroundColor [0.5, 0.5, 0.5, 0.9]; _ctrlBackground ctrlSetText "ENTER TEXT:"; _ctrlBackground ctrlEnable false; _ctrlBackground ctrlCommit 0; _ctrlEdit ctrlSetPosition [0.01, 0.05, 0.48, 0.34]; _ctrlEdit ctrlSetBackgroundColor [0, 0, 0, 0.5]; _ctrlEdit ctrlCommit 0; _ctrlButton ctrlSetPosition [0.185, 0.42, 0.13, 0.05]; _ctrlButton ctrlCommit 0; _ctrlButton ctrlSetText "SUBMIT"; _ctrlButton ctrlAddEventHandler ["ButtonClick", { params ["_ctrl"]; _display = ctrlParent _ctrl; _text = ctrlText (_display displayCtrl IDD_EDIT_BOX); if (_text == "") then { _text = "EMPTY" }; hint _text; _display closeDisplay 1; }]; ctrlSetFocus _ctrlEdit; _ctrlGroup ctrlSetPosition [0.25, 0.25, 0.5, 0.5]; _ctrlGroup ctrlCommit 0.1;

playSound "Hint3";

Additional Information

See also:
allControlsallDisplayscontrolsGroupCtrlctrlDeletectrlModelctrlSetModelctrlPositionctrlSetPositionctrlClassNamectrlModelScalectrlSetModelScalectrlModelDirAndUpctrlSetModelDirAndUpdisplayParent

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note

Notes

Bottom Section


Posted on September 16, 2019 - 07:09 (UTC)
R3vo
Regarding search speed in example 4: The search is incredible slow if items are only added to the first level. As soon as multiple levels are added, the search becomes faster.
Therefore it is not recommended to use a TreeView control as listbox just to have access to the engine driven incremental search.