DxAddClickFunction: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "{{Client function}} __NOTOC__ This function allows you to bind a function to a DxElement's click handler. ==Syntax== <syntaxhighlight lang="lua"> bool dxAddClickFunction ( D...")
 
(delete)
Tag: Blanking
 
Line 1: Line 1:
{{Client function}}
__NOTOC__
This function allows you to bind a function to a DxElement's click handler.


==Syntax==
<syntaxhighlight lang="lua">
bool dxAddClickFunction ( DxElement dxElement, function handlerFunction )
</syntaxhighlight>
{{OOP||DxElement:addClickFunction}}
===Required Arguments===
*'''dxElement:''' element you wish to bind a click function to
*'''handlerFunction:''' the handler function you wish to bind
===Returns===
Returns true if the function was bound successfully, false otherwise.
==Example==
This example prints a message to the chatbox every time a DxButton is left clicked (down).
<syntaxhighlight lang="lua">
local button = DxButton:new(0, 0, 100, 35, "Button")
function myButtonFunction(button, state)
    if(button == "left" and state == "down") then
        outputChatBox("hello")
    end
end
dxAddClickFunction(button, myButtonFunction)
</syntaxhighlight>
==See Also==
{{TDX_general_functions}}

Latest revision as of 12:11, 25 September 2021