ctrlMapCursor: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Text replacement - "\|s([0-9])\= ([^' ]+)'''([^' ]+)'''([^ ]*) " to "|s$1= $2$3$4 ") |
Lou Montana (talk | contribs) m (Some wiki formatting) |
||
Line 15: | Line 15: | ||
|gr1= GUI Control - Map | |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. | |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. | ||
* 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 | {{Feature|important|Before {{arma3}}, if the specified cursor does not exist the default is used and no error is produced.<br> | ||
* 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) | In {{arma3}}, this would result in the following error: <tt>"No entry 'bin\config.bin/CfgWrapperUI/Cursors'"</tt>. | ||
Some possible class names ( | }} | ||
The cursor is the name of a config entry from ''CfgWrapperUI / Cursors''. This command has the following specifics: | |||
* When used on the Main Map ({{ic|[[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 {{HashLink|#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 {{HashLink|#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 34: | Line 39: | ||
* HC_overMission | * HC_overMission | ||
* HC_unsel | * HC_unsel | ||
}} | |||
|s1= control [[ctrlMapCursor]] [defaultCursor, newCursor] | |s1= control [[ctrlMapCursor]] [defaultCursor, newCursor] | ||
Line 40: | Line 45: | ||
|p1= control: [[Control]] - Map control | |p1= control: [[Control]] - Map control | ||
|p2= defaultCursor: [[String]] - | |p2= defaultCursor: [[String]] - cursor class name, '''case-sensitive''' | ||
|p3= newCursor: [[String]] - | |p3= newCursor: [[String]] - cursor class name, '''case-sensitive''' | ||
|r1= [[Nothing]] | |r1= [[Nothing]] | ||
Line 48: | Line 53: | ||
|x1= <code>_map [[ctrlMapCursor]] ["Track", "Arrow"];</code> | |x1= <code>_map [[ctrlMapCursor]] ["Track", "Arrow"];</code> | ||
|x2= <code>[[uiNamespace]] [[setVariable]] ["_map",[[findDisplay]] 12 [[displayCtrl]] 51]; | |x2= <code>[[uiNamespace]] [[setVariable]] ["_map", [[findDisplay]] 12 [[displayCtrl]] 51]; | ||
([[uiNamespace]] [[getVariable]] "_map") [[ctrlMapCursor]] ["Track","HC_overFriendly"];</code> | ([[uiNamespace]] [[getVariable]] "_map") [[ctrlMapCursor]] ["Track", "HC_overFriendly"];</code> | ||
|x3= <code>[[findDisplay]] 12 [[displayCtrl]] 51 [[ctrlMapCursor]] ["Scroll", "Wait"];</code> | |x3= <code>[[findDisplay]] 12 [[displayCtrl]] 51 [[ctrlMapCursor]] ["Scroll", "Wait"];</code> | ||
|x4= Cycle through all available cursors over custom map:<code>[] [[spawn]] | |x4= Cycle through all available cursors over custom map: | ||
<code>[] [[spawn]] | |||
{ | { | ||
[[disableSerialization]]; | [[disableSerialization]]; | ||
Line 70: | Line 76: | ||
}} | }} | ||
{{Note | |||
|user= Bull A | |||
|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: | |||
<code>_control [[ctrlAddEventHandler]] ["MouseMoving", { | |||
[[params]] [ | |||
["_mapCtrl",[[controlNull]], [<nowiki/>[[controlNull]]]], | |||
["_xPos",-1,[0]], | |||
["_yPos",-1,[0]], | |||
["_mouseIn", [[false]], [<nowiki/>[[true]]]] | |||
]; | |||
[[if]] (_mouseIn) [[then]] { | |||
{{cc|Mouse is in control area}} | |||
_mapCtrl [[ctrlMapCursor]] ["", "Track"]; | |||
} [[else]] { | |||
{{cc|Mouse is out of control area, goes back to arrow}} | |||
_mapCtrl [[ctrlMapCursor]] ["", "Arrow"]; | |||
}; | |||
}]; | }]; | ||
</code> | </code> | ||
}} | |||
Revision as of 21:00, 21 September 2021
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.
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
- When used on the Main Map (
- 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:
[] 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:
- setMousePositiongetMousePosition
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 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"]; }; }];