CustomWidget:addEvent: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{Client function}} This function adding to Custom Widget event. == Syntax == <syntaxhighlight lang="lua"> nil CustomWidget:addEvent(string EventName, function Even...")
 
 
(2 intermediate revisions by the same user not shown)
Line 5: Line 5:
== Syntax ==
== Syntax ==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
nil CustomWidget:addEvent(string EventName, function EventFunction)
function CustomWidget:addEvent(string EventName, function EventFunction)
</syntaxhighlight>
</syntaxhighlight>


Line 11: Line 11:
*'''EventName''' - Default MTA event names, and custom events.
*'''EventName''' - Default MTA event names, and custom events.
*'''EventFunction''' - Function to execute when event happening.
*'''EventFunction''' - Function to execute when event happening.
=== Returns ===
Returns updated function for '''addEventHandler''', special for removing function ([[CustomWidget:removeEvent]])


== Information ==
== Information ==
Line 22: Line 25:
Window:setCloseEnabled(true)
Window:setCloseEnabled(true)


local Button = CustomButton.create(10, 25, 60, 25, "Click Me", false, Window:getFrame())
local Button = CustomButton.create(10, 25, 60, 25, "Click Me", false, Window)
Button:addEvent("onClientGUIClick", function()
Button:addEvent("onClientGUIClick", function()
outputChatBox("You've clicked the button")
outputChatBox("You've clicked the button")

Latest revision as of 12:28, 5 September 2018

This function adding to Custom Widget event.

Syntax

function CustomWidget:addEvent(string EventName, function EventFunction)

Required Arguments

  • EventName - Default MTA event names, and custom events.
  • EventFunction - Function to execute when event happening.

Returns

Returns updated function for addEventHandler, special for removing function (CustomWidget:removeEvent)

Information

Do not use events, what haven't source element as GUI-Element, like onClientRender, and etc.

Example

This example creating window with button, what sends message in chat on click, and event when window close sends info in chat:

local Window = CustomWindow.create(50, 50, 80, 60, "Example", false)
Window:setCloseEnabled(true)

local Button = CustomButton.create(10, 25, 60, 25, "Click Me", false, Window)
Button:addEvent("onClientGUIClick", function()
	outputChatBox("You've clicked the button")
end)

Window:addEvent("onCustomWindowClose", function()
	outputChatBox("You've closed window")
end)

See Also

Resource Wiki with content located here: Resource:CustomWidgets

Custom Widgets

This methods working for all elements except CustomDialogs and CustomTooltips

Set Functions

Get Functions

Event Functions


Custom Windows

Create Function

Set Functions

Get Functions

Event Functions


Custom Buttons

Create Function

Set Functions

Get Functions

Event Functions


Custom Progress Bars

Create Function

Set Functions

Get Functions

Event Functions


Custom Scroll Bars

Create Function

Set Functions

Get Functions


Custom Edit Boxes

All functions, what has mark CustomEditBox available for CustomEdit, CustomMemo and CustomSpinner.

Create Functions

Set Functions

Get Functions

Event Functions


Custom Check Boxes

Create Function

Set Functions

Get Functions

Event Functions


Custom Combo Boxes

Create Function

Set Functions

Get Functions

Event Functions


Custom Tabbed Panels

Create Function

Set Functions

Get Functions

Event Functions


Custom Labels

Create Function

Set Functions

Get Functions

Event Functions


Custom Dialogs

Create Function

Event Functions


Custom Tool Tips

Create Function

Set Function

Get Function


Custom Loadings

Create Function

Set Functions

Get Functions


Custom Scroll Panes

Create Function

Set Functions

Get Functions

Event Functions


Custom Table Views

Create Function

Set Functions

Get Functions

Event Functions


Custom Static Images

Create Function

Set Function

Get Function

Event Functions


Custom Text Boxes

Create Function

Set Function

Get Function


Custom Events


Other about Custom Widgets