{"name":"findDisplay","operator":null,"title":"findDisplay","type":"command","url":"https://community.bistudio.com/wiki/findDisplay","revid":369048,"updated":"2024-09-02T20:24:49Z","groups":["GUI Control"],"status":"ok","replaced_by":[],"games":[{"game":"arma1","name":"Armed Assault","version":"1.00"},{"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":"arma1","name":"Armed Assault","version":"1.00"},"arma3_since":"0.50","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"description":"Finds a display by its IDD which can either be defined in missionConfigFile (description.ext) or configFile (config.cpp) or by its UI On Texture's unique name (see displayUniqueName).\n\nIf the specified display cannot be found, displayNull is returned.\n\n> [!IMPORTANT]\n> Dedicated servers and headless clients do not have a primary display (e.g `findDisplay 46` will return displayNull).\n>\n> Detect both with the hasInterface command.\n\n> [!NOTE]\n> For a list of (almost) all Arma 3's IDDs, see Arma 3: IDD List.","syntaxes":[{"syntax":"findDisplay idd","since":null,"effect":null,"exec":null,"params":[{"name":"idd","type":"Number","optional":false,"default":null,"description":null,"types":["Number"],"since":null,"text":"idd: Number"}],"returns":{"type":"Display","types":["Display"],"description":null,"text":"Display"},"form":"unary","operator":null,"left":null,"right":{"text":"idd","types":["Number"]}},{"syntax":"findDisplay displayName","since":"arma3 2.12","effect":null,"exec":null,"params":[{"name":"displayName","type":"String","optional":false,"default":null,"description":null,"types":["String"],"since":null,"text":"displayName: String"}],"returns":{"type":"Display","types":["Display"],"description":null,"text":"Display"},"form":"unary","operator":null,"left":null,"right":{"text":"displayName","types":["String"]}}],"examples":[{"text":"```sqf\n0 spawn\n{\n    waitUntil { !isNull findDisplay 46 };\n    hint \"Mission Display is now available!\";\n};\n```","code":["0 spawn\n{\n\twaitUntil { !isNull findDisplay 46 };\n\thint \"Mission Display is now available!\";\n};"]},{"text":"```sqf\n_display = findDisplay 1;\n```","code":["_display = findDisplay 1;"]},{"text":"```sqf\nprivate _display = findDisplay \"RscDisplayRenderTest\";\n```","code":["private _display = findDisplay \"RscDisplayRenderTest\";"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["allDisplays","displayCtrl","createDisplay","createDialog","dialog","displayNull","controlNull","isNull","ctrlCreate","displayParent","displayUniqueName"],"notes":[{"user":"Lou Montana","date":"2019-07-07T12:20:00Z","text":"Common IDDs:\n- 46: Mission display\n- 312: Zeus display\n- 49: Pause menu\n- 602: Inventory\n- 24: Chat box\n- 300: Weapon state\n- 12: Map\n- 160: UAV Terminal"},{"user":"Kronzky","date":"2009-06-15T19:10:00Z","text":"findDisplay does *not* find displays defined under RscTitles (even when they are visible).\n\nTo access those types of displays, either assign the resource to a global variable, or pass its this value to a script, during the onLoad event:\ne.g. \n\n```cpp\nclass RscTitles\n{\n    class MyRsc\n    {\n        onLoad = \"myDisplay = (_this select 0)\";\n        // or\n        // onLoad = \"_this execVM 'myDialog.sqf'\";\n        // ...\n    };\n};\n```\n\nYou can then use the stored value as you would for regular dialogs:\n\n```sqf\n(myDisplay displayCtrl 1111) ctrlSetText \"hello there\");\n```"},{"user":"Nelis75733126","date":"2017-06-25T09:32:00Z","text":"I have tested the behavior of this command and I found out that `findDisplay` appears to only return the display AFTER any onLoad event handler of that display is done.\n\nMeaning: using findDisplay inside the code of an onLoad event handler is useless."},{"user":"Demellion","date":"2017-08-14T12:22:00Z","text":"There are some specific cases, where findDisplay will not be able to find an existing display. Here's the cases and how to act on them:\n\n```cpp\n// Your display has IDD= -1.\nclass RscDisplayNew\n{\n    idd = -1;\n    scriptName = \"RscDisplayNew\";\n    // ...\n};\n```\n\n```cpp\n// Your display doesn't have IDD\nclass RscDisplayNew\n{\n    scriptName = \"RscDisplayNew\";\n    // ...\n};\n```\n\n```cpp\n// Your display doesn't have scriptname with IDD = -1\nclass RscDisplayNew\n{\n    idd = -1;\n    // ...\n};\n```\n\n```cpp\n// Your display doesn't have scriptname, neither IDD\nclass RscDisplayNew\n{\n    // ...\n};\n```\n\n1. You actually can find a -1 display, but this means finding a display with this IDD might be a problem, when there are a few displays marked as -1.So as you can see, theres an entry called **scriptName**. You can get a reference to this display by using uiNamespace:\n\n```sqf\n(uiNamespace getVariable \"RscDisplayNew\")\n```\n\n**NOTE**: Variables are overwritten with a reference of the last declared display under the same scriptName entry. Take a look at case 3 for solution.\n1. Displays without IDDs can actually exist. They can be manipulated only in a way described in the first case using uiNamespace.\n1. You can really have this display seeking it manually in a allDisplays return. This is experimental, but working option.\n1. You will have a problem finding this display, since this display doesn't exist even in allDisplays(?) return. Behaviour unknown."},{"user":"AVespade","date":"2023-05-07T02:55:58Z","text":"Since findDisplay is case-sensitive, and any UI On Texture unique names defined inside a p3d file will always be forced to lowercase, the unique name you search for with findDisplay will need to be lowercase.\n\n```sqf\nprivate _display = findDisplay \"rscdisplayrendertest\";\n```\n\nUse of toLower may be useful to improve legibility or flow, especially in cases where a UI On Texture's unique name is the same as the class name.\n\n```sqf\nprivate _display = findDisplay (toLower \"RscDisplayRenderTest\");\n```"}],"categories":["ArmA: Armed Assault: New Scripting Commands","ArmA: Armed Assault: Scripting Commands","Arma 2: Operation Arrowhead: Scripting Commands","Arma 2: Scripting Commands","Arma 3: Scripting Commands","Command Group: GUI Control","Introduced with Armed Assault version 1.00","Scripting Commands","Take On Helicopters: Scripting Commands"]}