ctrlMapCursor: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (template:command argument fix)
m (Text replacement - "[] spawn" to "0 spawn")
 
(62 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Command|= Comments
{{RV|type=command
____________________________________________________________________________________________


| arma2 |= Game name
|game1= arma2
|version1= 1.00


|1.00|= Game version
|game2= arma2oa
____________________________________________________________________________________________
|version2= 1.50


| Changes the default cursor that appears when interacting with a map control to a custom one. Use an empty string to restore the default cursor. If the specified cursor does not exist, the default is used and no error is produced. ( NOT in case of ArmA 3. Using an empty string will result in an error: "No entry 'bin\config.bin/CfgWrapperUI/Cursors.' ). The cursor is the name of a config entry from ''CfgWrapperUI / Cursors''. This command has the following specifics:
|game3= tkoh
* When used on Main Map ([[findDisplay]] 12 [[displayCtrl]] 51) it is possible to override multiple default cursors. For example, while leaving default "Arrow" intact, it is possible to just override "Scroll" with lets say "Wait" (Example 3)
|version3= 1.00
* When used on a custom map, for example user made Mini Map, there is only one single cursor "" for everything, therefore only this cursor can be overridden (see Example 4 on how to override it)
 
Some possible class names (for the whole list see [[ctrlMapCursor/cursors]]):
|game4= arma3
|version4= 0.50
 
|gr1= GUI Control - Map
 
|descr= Changes the default cursor that appears when interacting with a map control to a custom one. Use an empty string to restore the default cursor.
{{Feature|important|Before {{arma3}}, if the specified cursor does not exist the default is used and no error is produced.<br>
In {{arma3}}, this would result in the following error: {{hl|"No entry 'bin\config.bin/CfgWrapperUI/Cursors'"}}.
}}
The cursor is the name of a config entry from ''CfgWrapperUI / Cursors''. This command has the following specifics:
* When used on the Main Map (<sqf inline>findDisplay 12 displayCtrl 51</sqf>), it is possible to override multiple default cursors. For example, while leaving default "Arrow" intact, it is possible to just override "Scroll" with e.g "Wait" (See {{Link|#Example 3}})
* When used on a custom map, for example user made Mini Map, there is only one single cursor "" for everything, therefore only this cursor can be overridden (see {{Link|#Example 4}} on how to override it)
Some possible class names (See [[ctrlMapCursor/cursors]] for the whole list):
{{Columns|4|
* Arrow
* Arrow
* Track
* Track
Line 26: Line 39:
* HC_overMission
* HC_overMission
* HC_unsel
* HC_unsel
'''NOTE1''': Cursor names are '''case sensitive'''.|DESCRIPTION=
}}
____________________________________________________________________________________________
 
| control '''ctrlMapCursor''' [defaultCursor, newCursor] |SYNTAX=


|p1= control: [[Control]] - Map control |PARAMETER1=
|s1= control [[ctrlMapCursor]] [defaultCursor, newCursor]


|p2= defaultCursor: [[String]] - Cursor class name |PARAMETER2=
|p1= control: [[Control]] - map control


|p3= newCursor: [[String]] - Cursor class name |PARAMETER3=
|p2= defaultCursor: [[String]] - cursor class name, '''case-sensitive'''


| [[Nothing]] |RETURNVALUE=
|p3= newCursor: [[String]] - cursor class name, '''case-sensitive'''


|r1= [[Nothing]]


|x1= <code>_map [[ctrlMapCursor]] ["Track", "Arrow"];</code>|EXAMPLE1=
|x1= <sqf>_map ctrlMapCursor ["Track", "Arrow"];</sqf>


|x2= <code>[[uiNamespace]] [[setVariable]] ["_map",[[findDisplay]] 12 [[displayCtrl]] 51];
|x2= <sqf>
([[uiNamespace]] [[getVariable]] "_map") [[ctrlMapCursor]] ["Track","HC_overFriendly"];</code>|EXAMPLE2=
uiNamespace setVariable ["_map", findDisplay 12 displayCtrl 51];
(uiNamespace getVariable "_map") ctrlMapCursor ["Track", "HC_overFriendly"];
</sqf>


|x3= <code>[[findDisplay]] 12 [[displayCtrl]] 51 [[ctrlMapCursor]] ["Scroll", "Wait"];</code>|EXAMPLE3=
|x3= <sqf>findDisplay 12 displayCtrl 51 ctrlMapCursor ["Scroll", "Wait"];</sqf>


|x4= Cycle through all available cursors over custom map:<code>0 = [] [[spawn]]
|x4= Cycle through all available cursors over custom map:
{
<sqf>
[[disableSerialization]];
0 spawn
_map = [[findDisplay]] 46 [[createDisplay]] "RscCredits" [[ctrlCreate]] ["RscMapControl", -1];
{
_map [[ctrlSetPosition]] [0,0,1,1];
disableSerialization;
_map [[ctrlCommit]] 0;
_map = findDisplay 46 createDisplay "RscCredits" ctrlCreate ["RscMapControl", -1];
_map ctrlSetPosition [0,0,1,1];
_map ctrlCommit 0;
{
{
_map [[ctrlMapCursor]] ["", [[configName]] _x]; //<-- the actual usage
_map ctrlMapCursor ["", configName _x]; //<-- the actual usage
[[hint]] [[format]] ["Current cursor: %1", [[configName]] _x];
hint format ["Current cursor: %1", configName _x];
[[sleep]] 1;
sleep 1;
}  
}
[[forEach]] ("true" [[configClasses]] ([[configFile]] >> "CfgWrapperUI" >> "Cursors"));
forEach ("true" configClasses (configFile >> "CfgWrapperUI" >> "Cursors"));
};</code>|EXAMPLE4=
};
 
</sqf>
____________________________________________________________________________________________


| [[setMousePosition]], [[getMousePosition]] |SEEALSO=
|seealso= [[setMousePosition]] [[getMousePosition]]
 
|  |MPBEHAVIOUR=
____________________________________________________________________________________________
}}
}}


<h3 style='display:none'>Notes</h3>
{{Note
<dl class='command_description'>
|user= Bull A
<!-- Note Section BEGIN -->
|timestamp= 20160208224300
 
|text= When using this command, the cursor will change for the whole display, resulting in visual glitches. Adding the onMouseMoving event handler can help solve this problem:
<!-- Note Section END -->
<sqf>
</dl>
_control ctrlAddEventHandler ["MouseMoving", {
 
params [
<h3 style='display:none'>Bottom Section</h3>
["_mapCtrl",controlNull, [controlNull]],
[[Category:ArmA 2: New Scripting Commands List|{{uc:{{PAGENAME}}}}]]
["_xPos",-1,[0]],
[[Category:Scripting Commands ArmA2|{{uc:{{PAGENAME}}}}]]
["_yPos",-1,[0]],
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
["_mouseIn", false, [true]]
[[Category:Scripting_Commands_Take_On_Helicopters|{{uc:{{PAGENAME}}}}]]
];
[[Category:Command_Group:_GUI_Control|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]


<!-- CONTINUE Notes -->
if (_mouseIn) then {
<dl class="command_description">
// Mouse is in control area
<dd class="notedate">Posted on February 8, 2016 - 22:43 (UTC)</dd>
_mapCtrl ctrlMapCursor ["", "Track"];
<dt class="note">[[User:Bull A|Bull A]]</dt>
} else {
<dd class="note">
// Mouse is out of control area, goes back to arrow
When using this command, the cursor will change for the whole display, resulting in visual glitches. Adding the onMouseMoving event handler can help solve this problem:
_mapCtrl ctrlMapCursor ["", "Arrow"];
<code>
};
_control [[ctrlAddEventHandler]] ["MouseMoving",{
  _this [[params]] [
      ["_mapCtrl",[[controlNull]],[[[controlNull]]]],
      ["_xPos",-1,[0]],
      ["_yPos",-1,[0]],
      ["_mouseIn",[[false]],[[[true]]]]
  ];
 
  if (_mouseIn) then {
      // Mouse is in control area
      _mapCtrl [[ctrlMapCursor]] ["","Track"];
  } else {
      // Mouse is out of control area, goes back to arrow
      _mapCtrl [[ctrlMapCursor]] ["","Arrow"];
  };
}];
}];
</code>
</sqf>
</dd>
}}
</dl>
<!-- DISCONTINUE Notes -->

Latest revision as of 21:24, 2 September 2024

Hover & click on the images for description

Description

Description:
Changes the default cursor that appears when interacting with a map control to a custom one. Use an empty string to restore the default cursor.
Before Arma 3, if the specified cursor does not exist the default is used and no error is produced.
In Arma 3, this would result in the following error: "No entry 'bin\config.bin/CfgWrapperUI/Cursors'".

The cursor is the name of a config entry from CfgWrapperUI / Cursors. This command has the following specifics:

  • When used on the Main Map (findDisplay 12 displayCtrl 51), it is possible to override multiple default cursors. For example, while leaving default "Arrow" intact, it is possible to just override "Scroll" with e.g "Wait" (See Example 3)
  • When used on a custom map, for example user made Mini Map, there is only one single cursor "" for everything, therefore only this cursor can be overridden (see Example 4 on how to override it)

Some possible class names (See ctrlMapCursor/cursors for the whole list):

  • Arrow
  • Track
  • Move
  • Scroll
  • Rotate
  • Track3D
  • Move3D
  • Rotate3D
  • Raise3D
  • Wait
  • HC_move
  • HC_overFriendly
  • HC_overEnemy
  • HC_overMission
  • HC_unsel
Groups:
GUI Control - Map

Syntax

Syntax:
control ctrlMapCursor [defaultCursor, newCursor]
Parameters:
control: Control - map control
defaultCursor: String - cursor class name, case-sensitive
newCursor: String - cursor class name, case-sensitive
Return Value:
Nothing

Examples

Example 1:
_map ctrlMapCursor ["Track", "Arrow"];
Example 2:
uiNamespace setVariable ["_map", findDisplay 12 displayCtrl 51]; (uiNamespace getVariable "_map") ctrlMapCursor ["Track", "HC_overFriendly"];
Example 3:
findDisplay 12 displayCtrl 51 ctrlMapCursor ["Scroll", "Wait"];
Example 4:
Cycle through all available cursors over custom map:
0 spawn { disableSerialization; _map = findDisplay 46 createDisplay "RscCredits" ctrlCreate ["RscMapControl", -1]; _map ctrlSetPosition [0,0,1,1]; _map ctrlCommit 0; { _map ctrlMapCursor ["", configName _x]; //<-- the actual usage hint format ["Current cursor: %1", configName _x]; sleep 1; } forEach ("true" configClasses (configFile >> "CfgWrapperUI" >> "Cursors")); };

Additional Information

See also:
setMousePosition getMousePosition

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
Bull A - c
Posted on Feb 08, 2016 - 22:43 (UTC)
When using this command, the cursor will change for the whole display, resulting in visual glitches. Adding the onMouseMoving event handler can help solve this problem:
_control ctrlAddEventHandler ["MouseMoving", { params [ ["_mapCtrl",controlNull, [controlNull]], ["_xPos",-1,[0]], ["_yPos",-1,[0]], ["_mouseIn", false, [true]] ]; if (_mouseIn) then { // Mouse is in control area _mapCtrl ctrlMapCursor ["", "Track"]; } else { // Mouse is out of control area, goes back to arrow _mapCtrl ctrlMapCursor ["", "Arrow"]; }; }];