ctrlSetPosition: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "|Game version=" to "|Game version= |gr1= GUI Control |GROUP1= ")
m (Text replacement - "<sqf>([^↵][^\/]*↵[^\/]*)<\/sqf>" to "<sqf> $1 </sqf>")
 
(44 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Command|Comments=
{{RV|type=command
____________________________________________________________________________________________


| arma |Game name=
|game1= arma1
|version1= 1.00


|1.00|Game version=
|game2= arma2
|version2= 1.00


|gr1= GUI Control |GROUP1=
|game3= arma2oa
|version3= 1.50


|game4= tkoh
|version4= 1.00


|game5= arma3
|version5= 0.50


|gr1= GUI Control |=GROUP1
|gr1= GUI Control - Positioning
____________________________________________________________________________________________


| 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. |DESCRIPTION=
|descr= 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.
____________________________________________________________________________________________


| controlName '''ctrlSetPosition''' [x, y] |SYNTAX=
{{Feature|important| This command doesn't work well with [[CT_MAP]] control. Use [[ctrlMapSetPosition]] instead. }}


|p1= controlName: [[Control]] - 2D control|PARAMETER1=
|s1= controlName [[ctrlSetPosition]] [x, y]


|p2= [x, y]: [[Array]] |PARAMETER2=
|p1= controlName: [[Control]] - 2D control


| [[Nothing]] |RETURNVALUE=
|p2= x: [[Number]] - position in x


|p3= y: [[Number]] - position in y


| s2= controlName '''ctrlSetPosition''' [x, y, w, h] |SYNTAX2=
|r1= [[Nothing]]


|p21= controlName: [[Control]] - 2D control|PARAMETER21=
|s2= controlName [[ctrlSetPosition]] [x, y, w, h]


|p22= [x, y, w, h]: [[Array]] |PARAMETER2=
|p21= controlName: [[Control]] - 2D control


| r2= [[Nothing]] |RETURNVALUE=
|p22= x: [[Number]] - position in x


|p23= y: [[Number]] - position in y


| s3= controlName '''ctrlSetPosition''' [x, y, z] |SYNTAX3=
|p24= w: [[Number]] - width of the control


|p41= controlName: [[Control]] - 3D control|PARAMETER1=
|p25= h: [[Number]] - height of the control


|p42= [x, y, z]: [[Array]] - y is distance from the screen |PARAMETER2=
|r2= [[Nothing]]


| r3= [[Nothing]] |RETURNVALUE=
|s3= controlName [[ctrlSetPosition]] [x, z, y]
____________________________________________________________________________________________
|x1= Move control: <code>_control2D [[ctrlSetPosition]] [0, 0];
_control2D [[ctrlCommit]] 0;</code> |EXAMPLE1=
 
|x2= Move control and resize:<code>_control2D [[ctrlSetPosition]] [0, 0, 1, 1];
_control2D [[ctrlCommit]] 0;</code> |EXAMPLE2=


|x3= <code>_control3D [[ctrlSetPosition]] [0.5, 1, 0.5]; //centered and 1m away from screen</code> |EXAMPLE3=
|p41= controlName: [[Control]] - 3D control


|x4= Typewriter effect: <code>[[with]] [[uiNamespace]] [[do]]
|p42= x: [[Number]] - screen x
{
 
[] [[spawn]]
|p43= z: [[Number]] - distance from the screen (depth). If object is too far, it cannot be dragged by the mouse.
 
|p44= y: [[Number]] - screen y
 
|r3= [[Nothing]]
 
|x1= Move control:
<sqf>
_control2D ctrlSetPosition [0, 0];
_control2D ctrlCommit 0;
</sqf>
 
|x2= Move control and resize:
<sqf>
_control2D ctrlSetPosition [0, 0, 1, 1];
_control2D ctrlCommit 0;
</sqf>
 
|x3= <sqf>_control3D ctrlSetPosition [0.5, 1, 0.5]; //centered and 1m away from screen</sqf>
 
|x4= Typewriter effect:
<sqf>
with uiNamespace do
{
0 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.";
_text2 = "This took 10 seconds.";
_text2 = "This took 10 seconds.";
_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 [[ctrlSetPosition]] [0,0,0,0.1];
ctrl [[ctrlCommit]] 0;
ctrl [[ctrlSetStructuredText]] [[parseText]] [[format]] ["<t color='#ff0000' size='2.1'>%1</t>", _text1 [[splitString]] " " [[joinString]] "&amp;#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]] "&amp;#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]] "&amp;#160;"];
ctrl [[ctrlSetPosition]] [0,0,[[ctrlTextWidth]] ctrl,0.1];
ctrl [[ctrlCommit]] 2;
[[waitUntil]] {[[ctrlCommitted]] ctrl};
[[sleep]] 2;
[[ctrlDelete]] ctrl;
};
};</code>|EXAMPLE4=
____________________________________________________________________________________________


|  [[ctrlCommit]], [[ctrlCreate]], [[ctrlDelete]], [[ctrlModel]], [[ctrlSetModel]], [[ctrlPosition]], [[ctrlClassName]], [[displayCtrl]], [[ctrlModelScale]], [[ctrlSetModelScale]], [[ctrlModelDirAndUp]], [[ctrlSetModelDirAndUp]]  |SEEALSO=
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;


<h3 style="display:none">Notes</h3>
ctrl ctrlSetPosition [0,0,0,0.1];
<dl class="command_description">
ctrl ctrlCommit 0;
<!-- Note Section BEGIN -->
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;


<dd class="notedate">Posted on January 27, 2007 - 19:13
waitUntil {ctrlCommitted ctrl};
<dt class="note">[[User:Giova|Giova]]<dd class="note">IMPORTANT''
sleep 2;


You have to use [[ctrlCommit]] command to apply this effect(Arma v1.02.5103GER)
ctrl ctrlSetPosition [0,0,0,0.1];
<!-- Note Section END -->
ctrl ctrlCommit 0;
</dl>
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;


<h3 style="display:none">Bottom Section</h3>
waitUntil {ctrlCommitted ctrl};
sleep 2;


[[Category:Scripting Commands|CTRLSETPOSITION]]
ctrlDelete ctrl;
[[Category:Scripting Commands Armed Assault|CTRLSETPOSITION]]
};
[[Category:Command_Group:_GUI_Control|{{uc:{{PAGENAME}}}}]]
};
[[Category:Scripting Commands Arma 2|{{uc:{{PAGENAME}}}}]]
</sqf>
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Take On Helicopters|{{uc:{{PAGENAME}}}}]]


<!-- CONTINUE Notes -->
|seealso= [[ctrlMapSetPosition]] [[ctrlCommit]] [[ctrlCreate]] [[ctrlDelete]] [[ctrlModel]] [[ctrlSetModel]] [[ctrlPosition]] [[ctrlClassName]] [[displayCtrl]] [[ctrlModelScale]] [[ctrlSetModelScale]] [[ctrlModelDirAndUp]] [[ctrlSetModelDirAndUp]]
<dl class="command_description">
}}
<dd class="notedate">Posted on May 22, 2017 - 23:04 (UTC)</dd>
<dt class="note">[[User:Lucian|Lucian]]</dt>
<dd class="note">
If the target ctrl is part of a ctrlGroup, the position needs to be relative to the ctrlGroup position.
</dd>
</dl>
<!-- DISCONTINUE Notes -->


<!-- CONTINUE Notes -->
{{Note
<dl class="command_description">
|user= Yuval
<dd class="notedate">Posted on July 20, 2017 - 11:56 (UTC)</dd>
|timestamp= 20170620115600
<dt class="note">[[User:Yuval|Yuval]]</dt>
|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).
<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>
<!-- DISCONTINUE Notes -->

Latest revision as of 11:34, 3 September 2024

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, z, y]
Parameters:
controlName: Control - 3D control
x: Number - screen x
z: Number - distance from the screen (depth). If object is too far, it cannot be dragged by the mouse.
y: Number - screen y
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 { 0 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).