{"name":"ctrlMapCursor","operator":null,"title":"ctrlMapCursor","type":"command","url":"https://community.bistudio.com/wiki/ctrlMapCursor","revid":369056,"updated":"2024-09-02T20:24:53Z","groups":["GUI Control - Map"],"status":"ok","replaced_by":[],"games":[{"game":"arma2","name":"Arma 2","version":"1.00"},{"game":"arma2oa","name":"Arma 2: Operation Arrowhead","version":"1.50"},{"game":"tkoh","name":"Take On Helicopters","version":"1.00"},{"game":"arma3","name":"Arma 3","version":"0.50"}],"since":{"game":"arma2","name":"Arma 2","version":"1.00"},"arma3_since":"0.50","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"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.\n\n> [!IMPORTANT]\n> Before Arma 3, if the specified cursor does not exist the default is used and no error is produced.\n>\n> In Arma 3, this would result in the following error: `\"No entry 'bin\\config.bin/CfgWrapperUI/Cursors'\"`.\n\nThe cursor is the name of a config entry from *CfgWrapperUI / Cursors*. This command has the following specifics:\n- 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)\n- 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)\nSome possible class names (See ctrlMapCursor/cursors for the whole list):\n- Arrow\n- Track\n- Move\n- Scroll\n- Rotate\n- Track3D\n- Move3D\n- Rotate3D\n- Raise3D\n- Wait\n- HC_move\n- HC_overFriendly\n- HC_overEnemy\n- HC_overMission\n- HC_unsel","syntaxes":[{"syntax":"control ctrlMapCursor [defaultCursor, newCursor]","since":null,"effect":null,"exec":null,"params":[{"name":"control","type":"Control","optional":false,"default":null,"description":"map control","types":["Control"],"since":null,"text":"control: Control - map control"},{"name":"defaultCursor","type":"String","optional":false,"default":null,"description":"cursor class name, **case-sensitive**","types":["String"],"since":null,"text":"defaultCursor: String - cursor class name, **case-sensitive**"},{"name":"newCursor","type":"String","optional":false,"default":null,"description":"cursor class name, **case-sensitive**","types":["String"],"since":null,"text":"newCursor: String - cursor class name, **case-sensitive**"}],"returns":{"type":"Nothing","types":["Nothing"],"description":null,"text":"Nothing"},"form":"binary","operator":null,"left":{"text":"control","types":["Control"]},"right":{"text":"[defaultCursor, newCursor]","types":["Array"]}}],"examples":[{"text":"```sqf\n_map ctrlMapCursor [\"Track\", \"Arrow\"];\n```","code":["_map ctrlMapCursor [\"Track\", \"Arrow\"];"]},{"text":"```sqf\nuiNamespace setVariable [\"_map\", findDisplay 12 displayCtrl 51];\n(uiNamespace getVariable \"_map\") ctrlMapCursor [\"Track\", \"HC_overFriendly\"];\n```","code":["uiNamespace setVariable [\"_map\", findDisplay 12 displayCtrl 51];\n(uiNamespace getVariable \"_map\") ctrlMapCursor [\"Track\", \"HC_overFriendly\"];"]},{"text":"```sqf\nfindDisplay 12 displayCtrl 51 ctrlMapCursor [\"Scroll\", \"Wait\"];\n```","code":["findDisplay 12 displayCtrl 51 ctrlMapCursor [\"Scroll\", \"Wait\"];"]},{"text":"Cycle through all available cursors over custom map:\n\n```sqf\n0 spawn\n{\n    disableSerialization;\n    _map = findDisplay 46 createDisplay \"RscCredits\" ctrlCreate [\"RscMapControl\", -1];\n    _map ctrlSetPosition [0,0,1,1];\n    _map ctrlCommit 0;\n    {\n        _map ctrlMapCursor [\"\", configName _x]; //<-- the actual usage\n        hint format [\"Current cursor: %1\", configName _x];\n        sleep 1;\n    }\n    forEach (\"true\" configClasses (configFile >> \"CfgWrapperUI\" >> \"Cursors\"));\n};\n```","code":["0 spawn\n{\n\tdisableSerialization;\n\t_map = findDisplay 46 createDisplay \"RscCredits\" ctrlCreate [\"RscMapControl\", -1];\n\t_map ctrlSetPosition [0,0,1,1];\n\t_map ctrlCommit 0;\n\t{\n\t\t_map ctrlMapCursor [\"\", configName _x]; //<-- the actual usage\n\t\thint format [\"Current cursor: %1\", configName _x];\n\t\tsleep 1;\n\t}\n\tforEach (\"true\" configClasses (configFile >> \"CfgWrapperUI\" >> \"Cursors\"));\n};"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["setMousePosition","getMousePosition"],"notes":[{"user":"Bull A","date":"2016-02-08T22:43:00Z","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:\n\n```sqf\n_control ctrlAddEventHandler [\"MouseMoving\", {\n    params [\n        [\"_mapCtrl\",controlNull, [controlNull]],\n        [\"_xPos\",-1,[0]],\n        [\"_yPos\",-1,[0]],\n        [\"_mouseIn\", false, [true]]\n    ];\n\n    if (_mouseIn) then {\n    // Mouse is in control area\n    _mapCtrl ctrlMapCursor [\"\", \"Track\"];\n    } else {\n    // Mouse is out of control area, goes back to arrow\n    _mapCtrl ctrlMapCursor [\"\", \"Arrow\"];\n    };\n}];\n```"}],"categories":["Arma 2: New Scripting Commands","Arma 2: Operation Arrowhead: Scripting Commands","Arma 2: Scripting Commands","Arma 3: Scripting Commands","Command Group: GUI Control - Map","Introduced with Arma 2 version 1.00","Scripting Commands","Take On Helicopters: Scripting Commands"]}