findDisplay: Difference between revisions

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


| arma |= Game name
|game1= arma1
|version1= 1.00


|1.00|= Game version
|game2= arma2
____________________________________________________________________________________________
|version2= 1.00


| Find display by its IDD (which is defined in the description.ext or config).<br>
|game3= arma2oa
If the specified display can't be found "No display" is returned (which can be tested with the [[isNull]] command.) |= Description
|version3= 1.50
____________________________________________________________________________________________


| [[Display]] <nowiki>=</nowiki> '''findDisplay''' idd |= Syntax
|game4= tkoh
|version4= 1.00


|p1= idd: [[Number]] |= Parameter 1
|game5= arma3
|version5= 0.50


| [[Display]] |= Return value
|gr1= GUI Control
____________________________________________________________________________________________
 
|x1= <pre>_display = findDisplay 1</pre> |= Example 1
____________________________________________________________________________________________


| [[displayCtrl]] |= See also
|descr= Finds a display by its IDD which can either be defined in [[missionConfigFile]] ([[Description.ext|description.ext]]) or [[configFile]] ([[config.cpp]]) or by its [[Procedural Textures#UI On Texture|UI On Texture]]'s unique name (see [[displayUniqueName]]).<br>
If the specified display cannot be found, [[displayNull]] is returned.
{{Feature|important|
Dedicated servers and [[Arma 3: Headless Client|headless clients]] do not have a primary display (e.g <sqf inline>findDisplay 46</sqf> will return [[displayNull]]).<br>
Detect both with the [[hasInterface]] command.
}}
 
{{Feature|informative|For a list of (almost) all {{arma3}}'s IDDs, see [[Arma 3: IDD List]].}}
 
|s1= [[findDisplay]] idd
 
|p1= idd: [[Number]]
 
|r1= [[Display]]
 
|s2= [[findDisplay]] displayName
 
|s2since= arma3 2.12
 
|p21= displayName: [[String]]
 
|r2= [[Display]]
 
|x1= <sqf>
0 spawn
{
waitUntil { !isNull findDisplay 46 };
hint "Mission Display is now available!";
};
</sqf>
 
|x2= <sqf>_display = findDisplay 1;</sqf>
 
|x3= <sqf>private _display = findDisplay "RscDisplayRenderTest";</sqf>
 
|seealso= [[allDisplays]] [[displayCtrl]] [[createDisplay]] [[createDialog]] [[dialog]] [[displayNull]] [[controlNull]] [[isNull]] [[createDisplay]] [[ctrlCreate]] [[displayParent]] [[displayUniqueName]]
}}
 
{{Note
|user= Lou Montana
|timestamp= 20190707122000
|text= Common IDDs:
* 46: Mission display
* 312: Zeus display
* 49: Pause menu
* 602: Inventory
* 24: Chat box
* 300: Weapon state
* 12: Map
* 160: UAV Terminal
}}


{{Note
|user= Kronzky
|timestamp= 20090615191000
|text= [[findDisplay]] does ''not'' find displays defined under RscTitles (even when they are visible).<br>
To access those types of displays, either assign the resource to a global variable, or pass its [[Magic Variables#this_2|this]] value to a script, during the onLoad event:
e.g. <syntaxhighlight lang="cpp">
class RscTitles
{
class MyRsc
{
onLoad = "myDisplay = (_this select 0)";
// or
// onLoad = "_this execVM 'myDialog.sqf'";
// ...
};
};
</syntaxhighlight>
You can then use the stored value as you would for regular dialogs:
<sqf>(myDisplay displayCtrl 1111) ctrlSetText "hello there");</sqf>
}}
}}


<h3 style="display:none">Notes</h3>
{{Note
<dl class="command_description">
|user= Nelis75733126
<!-- Note Section BEGIN -->
|timestamp= 20170625093200
|text= I have tested the behavior of this command and I found out that <sqf inline>findDisplay</sqf> appears to only return the display AFTER any {{Link|User_Interface_Event_Handlers#onLoad|onLoad}} event handler of that display is done.<br>
Meaning: using [[findDisplay]] inside the code of an onLoad event handler is useless.
}}


<dd class="notedate">Posted on 15 June 2008</dd>
{{Note
<dt class="note>'''[[User:Kronzky|Kronzky]]'''</dt>
|user= Demellion
<dd class="note">
|timestamp= 20170814122200
findDisplay does ''not'' find displays defined under RscTitles (even when they are visible).<br>
|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:<br>
To 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:
<syntaxhighlight lang="cpp">
e.g. <pre>class RscTitles {
// Your display has IDD= -1.
  class MyRsc {
class RscDisplayNew
    onLoad = "myDisplay = (_this select 0)"; // or
{
    // onLoad = "_this execVM 'myDialog.sqf'";
idd = -1;
    ...
scriptName = "RscDisplayNew";
</pre>
// ...
You can then use the stored value as you would for regular dialogs, e.g.<code>(myDisplay displayCtrl 1111) ctrlSetText "hello there");</code>
};
</dd>
</syntaxhighlight>
<syntaxhighlight lang="cpp">
// Your display doesn't have IDD
class RscDisplayNew
{
scriptName = "RscDisplayNew";
// ...
};
</syntaxhighlight>
<syntaxhighlight lang="cpp">
// Your display doesn't have scriptname with IDD = -1
class RscDisplayNew
{
idd = -1;
// ...
};
</syntaxhighlight>
<syntaxhighlight lang="cpp">
// Your display doesn't have scriptname, neither IDD
class RscDisplayNew
{
// ...
};
</syntaxhighlight>


<!-- Note Section END -->
# 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.<!--
</dl>
-->So as you can see, theres an entry called '''scriptName'''. You can get a reference to this display by using [[uiNamespace]]:<!--
--><sqf>(uiNamespace getVariable "RscDisplayNew")</sqf><!--
-->'''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.
# Displays without IDDs can actually exist. They can be manipulated only in a way described in the first case using [[uiNamespace]].
# You can really have this display seeking it manually in a [[allDisplays]] return. This is experimental, but working option.
# You will have a problem finding this display, since this display doesn't exist even in [[allDisplays]](?) return. Behaviour unknown.
}}


<h3 style="display:none">Bottom Section</h3>
{{Note
|user= AVespade
|timestamp= 20230507025558
|text= Since findDisplay is case-sensitive, and any [[Procedural_Textures#UI_On_Texture|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.


[[Category:Scripting Commands|FINDDISPLAY]]
<sqf>private _display = findDisplay "rscdisplayrendertest";</sqf>
[[Category:Scripting Commands ArmA|FINDDISPLAY]]
 
[[Category:Command_Group:_GUI_Control|{{uc:{{PAGENAME}}}}]]
Use 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.
[[Category:Command_Group:_System_Commands|{{uc:{{PAGENAME}}}}]]
<sqf>private _display = findDisplay (toLower "RscDisplayRenderTest");</sqf>
[[Category:Scripting Commands ArmA2|{{uc:{{PAGENAME}}}}]]
}}

Latest revision as of 21:24, 2 September 2024

Hover & click on the images for description

Description

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).
If the specified display cannot be found, displayNull is returned.
Dedicated servers and headless clients do not have a primary display (e.g findDisplay 46 will return displayNull).
Detect both with the hasInterface command.
For a list of (almost) all Arma 3's IDDs, see Arma 3: IDD List.
Groups:
GUI Control

Syntax

Syntax:
findDisplay idd
Parameters:
idd: Number
Return Value:
Display

Alternative Syntax

Syntax:
findDisplay displayName
Parameters:
displayName: String
Return Value:
Display

Examples

Example 1:
0 spawn { waitUntil { !isNull findDisplay 46 }; hint "Mission Display is now available!"; };
Example 2:
_display = findDisplay 1;
Example 3:
private _display = findDisplay "RscDisplayRenderTest";

Additional Information

See also:
allDisplays displayCtrl createDisplay createDialog dialog displayNull controlNull isNull createDisplay ctrlCreate displayParent displayUniqueName

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
Lou Montana - c
Posted on Jul 07, 2019 - 12:20 (UTC)
Common IDDs:
  • 46: Mission display
  • 312: Zeus display
  • 49: Pause menu
  • 602: Inventory
  • 24: Chat box
  • 300: Weapon state
  • 12: Map
  • 160: UAV Terminal
Kronzky - c
Posted on Jun 15, 2009 - 19:10 (UTC)
findDisplay does not find displays defined under RscTitles (even when they are visible).
To 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: e.g.
class RscTitles
{
	class MyRsc
	{
		onLoad = "myDisplay = (_this select 0)";
		// or
		// onLoad = "_this execVM 'myDialog.sqf'";
		// ...
	};
};

You can then use the stored value as you would for regular dialogs:

(myDisplay displayCtrl 1111) ctrlSetText "hello there");

Nelis75733126 - c
Posted on Jun 25, 2017 - 09:32 (UTC)
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.
Meaning: using findDisplay inside the code of an onLoad event handler is useless.
Demellion - c
Posted on Aug 14, 2017 - 12:22 (UTC)
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:
// Your display has IDD= -1.
class RscDisplayNew
{
	idd = -1;
	scriptName = "RscDisplayNew";
	// ...
};
// Your display doesn't have IDD
class RscDisplayNew
{
	scriptName = "RscDisplayNew";
	// ...
};
// Your display doesn't have scriptname with IDD = -1
class RscDisplayNew
{
	idd = -1;
	// ...
};
// Your display doesn't have scriptname, neither IDD
class RscDisplayNew
{
	// ...
};
  1. 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:
    (uiNamespace getVariable "RscDisplayNew")
    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.
  2. Displays without IDDs can actually exist. They can be manipulated only in a way described in the first case using uiNamespace.
  3. You can really have this display seeking it manually in a allDisplays return. This is experimental, but working option.
  4. You will have a problem finding this display, since this display doesn't exist even in allDisplays(?) return. Behaviour unknown.
AVespade - c
Posted on May 07, 2023 - 02:55 (UTC)
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.
private _display = findDisplay "rscdisplayrendertest";
Use 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.
private _display = findDisplay (toLower "RscDisplayRenderTest");