ctrlSetPosition: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Text replacement - "<code>([^ ]*)\[\[([a-zA-Z0-9_]+)\]\]([^ ]*)<\/code>" to "<code>$1$2$3</code>") |
Lou Montana (talk | contribs) m (Text replacement - "<sqf>([^↵][^\/]*↵[^\/]*)<\/sqf>" to "<sqf> $1 </sqf>") |
||
(12 intermediate revisions by 2 users not shown) | |||
Line 20: | Line 20: | ||
|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. | |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. | ||
{{Feature| | {{Feature|important| This command doesn't work well with [[CT_MAP]] control. Use [[ctrlMapSetPosition]] instead. }} | ||
|s1= controlName [[ctrlSetPosition]] | |s1= controlName [[ctrlSetPosition]] [x, y] | ||
|p1= controlName: [[Control]] - 2D control | |p1= controlName: [[Control]] - 2D control | ||
|p2= x: [[Number]] - | |p2= x: [[Number]] - position in x | ||
|p3= y: [[Number]] - | |p3= y: [[Number]] - position in y | ||
|r1= [[Nothing]] | |r1= [[Nothing]] | ||
|s2= controlName [[ctrlSetPosition]] | |s2= controlName [[ctrlSetPosition]] [x, y, w, h] | ||
|p21= controlName: [[Control]] - 2D control | |p21= controlName: [[Control]] - 2D control | ||
|p22= x: [[Number]] - | |p22= x: [[Number]] - position in x | ||
|p23= y: [[Number]] - | |p23= y: [[Number]] - position in y | ||
|p24= w: [[Number]] - | |p24= w: [[Number]] - width of the control | ||
|p25= h: [[Number]] - | |p25= h: [[Number]] - height of the control | ||
|r2= [[Nothing]] | |r2= [[Nothing]] | ||
|s3= controlName [[ctrlSetPosition]] | |s3= controlName [[ctrlSetPosition]] [x, z, y] | ||
|p41= controlName: [[Control]] - 3D control | |p41= controlName: [[Control]] - 3D control | ||
|p42= x: [[Number]] - | |p42= x: [[Number]] - screen x | ||
|p43= | |p43= z: [[Number]] - distance from the screen (depth). If object is too far, it cannot be dragged by the mouse. | ||
|p44= | |p44= y: [[Number]] - screen y | ||
|r3= [[Nothing]] | |r3= [[Nothing]] | ||
|x1= Move control: | |x1= Move control: | ||
< | <sqf> | ||
_control2D | _control2D ctrlSetPosition [0, 0]; | ||
_control2D ctrlCommit 0; | |||
</sqf> | |||
|x2= Move control and resize: | |x2= Move control and resize: | ||
< | <sqf> | ||
_control2D | _control2D ctrlSetPosition [0, 0, 1, 1]; | ||
_control2D ctrlCommit 0; | |||
</sqf> | |||
|x3= < | |x3= <sqf>_control3D ctrlSetPosition [0.5, 1, 0.5]; //centered and 1m away from screen</sqf> | ||
|x4= Typewriter effect: | |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 = | ctrl = findDisplay 46 ctrlCreate ["RscStructuredText", -1]; | ||
ctrl | ctrl ctrlSetPosition [0,0,0,0.1]; | ||
ctrl | ctrl ctrlCommit 0; | ||
ctrl | ctrl ctrlSetStructuredText parseText format ["<t color='#ff0000' size='2.1'>%1</t>", _text1 splitString " " joinString " "]; | ||
ctrl | ctrl ctrlSetPosition [0,0,ctrlTextWidth ctrl,0.1]; | ||
ctrl | ctrl ctrlCommit 8; | ||
waitUntil {ctrlCommitted ctrl}; | |||
sleep 0.5; | |||
ctrl | ctrl ctrlSetPosition [0,0,0,0.1]; | ||
ctrl | ctrl ctrlCommit 0; | ||
ctrl | ctrl ctrlSetStructuredText parseText format ["<t color='#ff0000' size='2.1'>%1</t>", _text2 splitString " " joinString " "]; | ||
ctrl | ctrl ctrlSetPosition [0,0,ctrlTextWidth ctrl,0.1]; | ||
ctrl | ctrl ctrlCommit 2; | ||
waitUntil {ctrlCommitted ctrl}; | |||
sleep 2; | |||
ctrl | ctrl ctrlSetPosition [0,0,0,0.1]; | ||
ctrl | ctrl ctrlCommit 0; | ||
ctrl | ctrl ctrlSetStructuredText parseText format ["<t color='#00ff00' size='2.1'>%1</t>", _text3 splitString " " joinString " "]; | ||
ctrl | ctrl ctrlSetPosition [0,0,ctrlTextWidth ctrl,0.1]; | ||
ctrl | ctrl ctrlCommit 2; | ||
waitUntil {ctrlCommitted ctrl}; | |||
sleep 2; | |||
ctrlDelete ctrl; | |||
}; | }; | ||
};</ | }; | ||
</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]] | ||
}} | }} | ||
{{Note | |||
|user= Yuval | |||
|timestamp= 20170620115600 | |||
|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). | |||
}} | |||
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) | |||
Latest revision as of 11:34, 3 September 2024
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.
- 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:
- Example 2:
- Move control and resize:
- 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 " "]; 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 " "]; 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 " "]; 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
- 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).
Categories:
- Scripting Commands
- Introduced with Armed Assault version 1.00
- ArmA: Armed Assault: New Scripting Commands
- ArmA: Armed Assault: Scripting Commands
- Arma 2: Scripting Commands
- Arma 2: Operation Arrowhead: Scripting Commands
- Take On Helicopters: Scripting Commands
- Arma 3: Scripting Commands
- Command Group: GUI Control - Positioning