ctrlSetPosition: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "\|x([0-9])= *<code>([^<]*)<\/code>" to "|x$1= <sqf>$2</sqf>")
m (Some wiki formatting)
Line 59: Line 59:


|x1= Move control:
|x1= Move control:
<code>_control2D ctrlSetPosition [0, 0];
<sqf>_control2D ctrlSetPosition [0, 0];
_control2D ctrlCommit 0;</code>
_control2D ctrlCommit 0;</sqf>


|x2= Move control and resize:
|x2= Move control and resize:
<code>_control2D ctrlSetPosition [0, 0, 1, 1];
<sqf>_control2D ctrlSetPosition [0, 0, 1, 1];
_control2D ctrlCommit 0;</code>
_control2D ctrlCommit 0;</sqf>


|x3= <sqf>_control3D ctrlSetPosition [0.5, 1, 0.5]; //centered and 1m away from screen</sqf>
|x3= <sqf>_control3D ctrlSetPosition [0.5, 1, 0.5]; //centered and 1m away from screen</sqf>


|x4= Typewriter effect:
|x4= Typewriter effect:
<code>[[with]] [[uiNamespace]] [[do]]
<sqf>
with uiNamespace do
{  
{  
[] [[spawn]]
[] spawn
{
{
_text1 = "This is a simple demo of typewriter text effect with various speed.";
_text1 = "This is a simple demo of typewriter text effect with various speed.";
Line 77: Line 78:
_text3 = "This is a fast one, set for 2 seconds.";
_text3 = "This is a fast one, set for 2 seconds.";
ctrl = [[findDisplay]] 46 [[ctrlCreate]] ["RscStructuredText", -1];
ctrl = findDisplay 46 ctrlCreate ["RscStructuredText", -1];
ctrl [[ctrlSetPosition]] [0,0,0,0.1];
ctrl ctrlSetPosition [0,0,0,0.1];
ctrl [[ctrlCommit]] 0;
ctrl ctrlCommit 0;
ctrl [[ctrlSetStructuredText]] [[parseText]] [[format]] ["<t color='#ff0000' size='2.1'>%1</t>", _text1 [[splitString]] " " [[joinString]] "&amp;#160;"];
ctrl ctrlSetStructuredText parseText format ["<t color='#ff0000' size='2.1'>%1</t>", _text1 splitString " " joinString "&#160;"];
ctrl [[ctrlSetPosition]] [0,0,[[ctrlTextWidth]] ctrl,0.1];
ctrl ctrlSetPosition [0,0,ctrlTextWidth ctrl,0.1];
ctrl [[ctrlCommit]] 8;
ctrl ctrlCommit 8;
[[waitUntil]] {[[ctrlCommitted]] ctrl};
waitUntil {ctrlCommitted ctrl};
[[sleep]] 0.5;
sleep 0.5;
ctrl [[ctrlSetPosition]] [0,0,0,0.1];
ctrl ctrlSetPosition [0,0,0,0.1];
ctrl [[ctrlCommit]] 0;
ctrl ctrlCommit 0;
ctrl [[ctrlSetStructuredText]] [[parseText]] [[format]] ["<t color='#ff0000' size='2.1'>%1</t>", _text2 [[splitString]] " " [[joinString]] "&amp;#160;"];
ctrl ctrlSetStructuredText parseText format ["<t color='#ff0000' size='2.1'>%1</t>", _text2 splitString " " joinString "&#160;"];
ctrl [[ctrlSetPosition]] [0,0,[[ctrlTextWidth]] ctrl,0.1];
ctrl ctrlSetPosition [0,0,ctrlTextWidth ctrl,0.1];
ctrl [[ctrlCommit]] 2;
ctrl ctrlCommit 2;
[[waitUntil]] {[[ctrlCommitted]] ctrl};
waitUntil {ctrlCommitted ctrl};
[[sleep]] 2;
sleep 2;
ctrl [[ctrlSetPosition]] [0,0,0,0.1];
ctrl ctrlSetPosition [0,0,0,0.1];
ctrl [[ctrlCommit]] 0;
ctrl ctrlCommit 0;
ctrl [[ctrlSetStructuredText]] [[parseText]] [[format]] ["<t color='#00ff00' size='2.1'>%1</t>", _text3 [[splitString]] " " [[joinString]] "&amp;#160;"];
ctrl ctrlSetStructuredText parseText format ["<t color='#00ff00' size='2.1'>%1</t>", _text3 splitString " " joinString "&#160;"];
ctrl [[ctrlSetPosition]] [0,0,[[ctrlTextWidth]] ctrl,0.1];
ctrl ctrlSetPosition [0,0,ctrlTextWidth ctrl,0.1];
ctrl [[ctrlCommit]] 2;
ctrl ctrlCommit 2;
[[waitUntil]] {[[ctrlCommitted]] ctrl};
waitUntil {ctrlCommitted ctrl};
[[sleep]] 2;
sleep 2;
[[ctrlDelete]] ctrl;
ctrlDelete ctrl;
};
};
};</code>
};
</sqf>


|seealso= [[ctrlMapSetPosition]] [[ctrlCommit]] [[ctrlCreate]] [[ctrlDelete]] [[ctrlModel]] [[ctrlSetModel]] [[ctrlPosition]] [[ctrlClassName]] [[displayCtrl]] [[ctrlModelScale]] [[ctrlSetModelScale]] [[ctrlModelDirAndUp]] [[ctrlSetModelDirAndUp]]
|seealso= [[ctrlMapSetPosition]] [[ctrlCommit]] [[ctrlCreate]] [[ctrlDelete]] [[ctrlModel]] [[ctrlSetModel]] [[ctrlPosition]] [[ctrlClassName]] [[displayCtrl]] [[ctrlModelScale]] [[ctrlSetModelScale]] [[ctrlModelDirAndUp]] [[ctrlSetModelDirAndUp]]
}}
}}


<dl class="command_description">
{{Note
 
|user= Yuval
<dt></dt>
|timestamp= 20170620115600
<dd class="notedate">Posted on July 20, 2017 - 11:56 (UTC)</dd>
|text= If the target control is a controls' group, all the child controls of that group will be moved automatically (as their position is relative to the control group rather than the display).
<dt class="note">[[User:Yuval|Yuval]]</dt>
}}
<dd class="note">
If the target control is a controls' group, all the child controls of that group will be moved automatically (as their position is relative to the control group rather than the display)
</dd>
 
</dl>

Revision as of 21:15, 13 May 2022

Hover & click on the images for description

Description

Description:
Sets wanted position and size for 2D control animation. Width and height are optional. ctrlCommit is required to complete the operation. For 3D control, param is relative [x, y, z] and no ctrlCommit is required as it cannot be animated. If target control is inside a CT_CONTROLS_GROUP, the position needs to be relative to it.
This command doesn't work well with CT_MAP control. Use ctrlMapSetPosition instead.
Groups:
GUI Control - Positioning

Syntax 1

Syntax:
controlName ctrlSetPosition [x, y]
Parameters:
controlName: Control - 2D control
x: Number - Position in x
y: Number - Position in y
Return Value:
Nothing

Syntax 2

Syntax:
controlName ctrlSetPosition [x, y, w, h]
Parameters:
controlName: Control - 2D control
x: Number - Position in x
y: Number - Position in y
w: Number - Width of the control
h: Number - Height of the control
Return Value:
Nothing

Syntax 3

Syntax:
controlName ctrlSetPosition [x, y, z]
Parameters:
controlName: Control - 3D control
x: Number - Position in x
y: Number - Position in y (Distance from the screen)
z: Number - Position in z
Return Value:
Nothing

Examples

Example 1:
Move control:
_control2D ctrlSetPosition [0, 0]; _control2D ctrlCommit 0;
Example 2:
Move control and resize:
_control2D ctrlSetPosition [0, 0, 1, 1]; _control2D ctrlCommit 0;
Example 3:
_control3D ctrlSetPosition [0.5, 1, 0.5]; //centered and 1m away from screen
Example 4:
Typewriter effect:
with uiNamespace do { [] spawn { _text1 = "This is a simple demo of typewriter text effect with various speed."; _text2 = "This took 10 seconds."; _text3 = "This is a fast one, set for 2 seconds."; ctrl = findDisplay 46 ctrlCreate ["RscStructuredText", -1]; ctrl ctrlSetPosition [0,0,0,0.1]; ctrl ctrlCommit 0; ctrl ctrlSetStructuredText parseText format ["<t color='#ff0000' size='2.1'>%1</t>", _text1 splitString " " joinString "&#160;"]; ctrl ctrlSetPosition [0,0,ctrlTextWidth ctrl,0.1]; ctrl ctrlCommit 8; waitUntil {ctrlCommitted ctrl}; sleep 0.5; ctrl ctrlSetPosition [0,0,0,0.1]; ctrl ctrlCommit 0; ctrl ctrlSetStructuredText parseText format ["<t color='#ff0000' size='2.1'>%1</t>", _text2 splitString " " joinString "&#160;"]; ctrl ctrlSetPosition [0,0,ctrlTextWidth ctrl,0.1]; ctrl ctrlCommit 2; waitUntil {ctrlCommitted ctrl}; sleep 2; ctrl ctrlSetPosition [0,0,0,0.1]; ctrl ctrlCommit 0; ctrl ctrlSetStructuredText parseText format ["<t color='#00ff00' size='2.1'>%1</t>", _text3 splitString " " joinString "&#160;"]; ctrl ctrlSetPosition [0,0,ctrlTextWidth ctrl,0.1]; ctrl ctrlCommit 2; waitUntil {ctrlCommitted ctrl}; sleep 2; ctrlDelete ctrl; }; };

Additional Information

See also:
ctrlMapSetPosition ctrlCommit ctrlCreate ctrlDelete ctrlModel ctrlSetModel ctrlPosition ctrlClassName displayCtrl ctrlModelScale ctrlSetModelScale ctrlModelDirAndUp ctrlSetModelDirAndUp

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
Yuval - c
Posted on Jun 20, 2017 - 11:56 (UTC)
If the target control is a controls' group, all the child controls of that group will be moved automatically (as their position is relative to the control group rather than the display).