DxAddClickFunction

From Multi Theft Auto: Wiki
Revision as of 21:11, 22 March 2020 by LopSided (talk | contribs) (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...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This function allows you to bind a function to a DxElement's click handler.

Syntax

bool dxAddClickFunction ( DxElement dxElement, function handlerFunction )

OOP Syntax Help! I don't understand this!

Method: 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).

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)

See Also