DXX: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created blank page)
 
No edit summary
Line 1: Line 1:
<pageclass class="resource" subcaption="Resource"></pageclass>


{{OOP|Use a dot instead of a colon to access class methods|[[Dxx]].on}}
==Syntax==
<syntaxhighlight lang="lua">
bool Dxx.on(string eventName, function callbackFunction)
</syntaxhighlight>
===Required Arguments===
*'''eventName:''' The name of the event you're trying to listen for. Possible values are:
**'''click'''
**'''destroy'''
**'''change'''
*'''callbackFunction:''' This is the function that should receive the data returned from the remote server. The callback argument list should be:
**'''''responseData''''' - A string containing the remote response or "ERROR" if there was a problem
**'''''errno''''' - A number containing the error number or zero if there was no error.
*'''arguments...''' - The arguments that were passed into fetchRemote
<section name="Example" class="generic" show="true">
<syntaxhighlight lang="lua">
local win = Window(700, 400, 1000, 600, "cool window")
local btn = Button(55, 55, 125, 30, "click me")
btn.setParent(win)
btn.on("click", function() btn.value = "clicked" end)
</syntaxhighlight>
</section>

Revision as of 01:09, 27 May 2018


OOP Syntax Help! I don't understand this!

Note: Use a dot instead of a colon to access class methods
Method: Dxx.on(...)


Syntax

bool Dxx.on(string eventName, function callbackFunction)

Required Arguments

  • eventName: The name of the event you're trying to listen for. Possible values are:
    • click
    • destroy
    • change
  • callbackFunction: This is the function that should receive the data returned from the remote server. The callback argument list should be:
    • responseData - A string containing the remote response or "ERROR" if there was a problem
    • errno - A number containing the error number or zero if there was no error.
  • arguments... - The arguments that were passed into fetchRemote


Click to collapse [-]
Example
local win = Window(700, 400, 1000, 600, "cool window")
local btn = Button(55, 55, 125, 30, "click me")

btn.setParent(win)
btn.on("click", function() btn.value = "clicked" end)