GetResourceGUIElement: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 14: Line 14:


==Example==  
==Example==  
<section name="Client" class="client" show="true">
This example creates a window and a button with the cursor showing. If the player clicks on myButton then the window would be destroyed and the cursor would not show. (Not sure if this function works)
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">myWindow = guiCreateWindow ( 0, 0, 0.7, 0.5, "Information", true )
-- Add example
myButton = guiCreateButton ( 0.7, 0.1, 0.2, 0.1, "Output!", true, myWindow )
showCursor(true)
 
addEventHandler("onClientGUIClick",getResourceGUIElement(),function()
if(source == myButton)then
destroyElement(myWindow)
showCursor(false)
end
end,false)
</syntaxhighlight>
</syntaxhighlight>
</section>


==See Also==
==See Also==
{{Client_resource_functions}}
{{Client_resource_functions}}
[[Category:Needs Example]]
[[Category:Needs Example]]

Revision as of 18:53, 28 April 2012

This function retrieves a resource's GUI element. The resource's GUI element is the element in the element tree which is the default parent of all GUI elements that belong to a particular resource. This has the tag 'guiroot', and each resource has one of these.

Syntax

element getResourceGUIElement ( [resource theResource=getThisResource()] )

Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.

  • theResource: the resource whose GUI element we are getting. If not specified, assumes the current resource. (the resource returned from getThisResource)

Returns

Returns the root GUI element that contains all the other GUI elements.

Example

This example creates a window and a button with the cursor showing. If the player clicks on myButton then the window would be destroyed and the cursor would not show. (Not sure if this function works)

myWindow = guiCreateWindow ( 0, 0, 0.7, 0.5, "Information", true )
myButton = guiCreateButton ( 0.7, 0.1, 0.2, 0.1, "Output!", true, myWindow )
showCursor(true)

addEventHandler("onClientGUIClick",getResourceGUIElement(),function()
	if(source == myButton)then
		destroyElement(myWindow)
		showCursor(false)
	end
end,false)

See Also