{"name":"ctrlMapCursor","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","games":{"arma2":"1.00","arma2oa":"1.50","tkoh":"1.00","arma3":"0.50"},"since":"arma2 1.00","arma3_since":"0.50","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> 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\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)\n\nSome possible class names (See ctrlMapCursor/cursors for the whole list):\n\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]","params":[{"name":"control","type":"Control","description":"map control","type_expr":"Control"},{"name":"defaultCursor","type":"String","description":"cursor class name, **case-sensitive**","type_expr":"String"},{"name":"newCursor","type":"String","description":"cursor class name, **case-sensitive**","type_expr":"String"}],"returns":{"type":"Nothing","type_expr":"Nothing"},"form":"binary","left":{"text":"control"},"right":{"text":"[defaultCursor, newCursor]"}}],"examples":[{"code":["_map ctrlMapCursor [\"Track\", \"Arrow\"];"]},{"code":["uiNamespace setVariable [\"_map\", findDisplay 12 displayCtrl 51];\n(uiNamespace getVariable \"_map\") ctrlMapCursor [\"Track\", \"HC_overFriendly\"];"]},{"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};"]}],"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```"}]}