DxAddClickFunction

From Multi Theft Auto: Wiki
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