Add some info on Events to ReadMe

This commit is contained in:
Josh
2018-05-31 14:20:56 -05:00
parent 6f199dfd6c
commit faa4294b2e
2 changed files with 19 additions and 5 deletions

View File

@@ -29,6 +29,11 @@ local scene = JUI.UIContainer:new()
local frame = JUI.Frame:new()
frame:setBackgroundColor(JUI.RGBColor:new(255, 128, 128))
-- connect a new event listener
frame.mouseEnter:connect(function()
end)
JUI.parent(scene, frame) -- the current method of setting the parent of an object
-- first object is the new parent of the second object
-- I don't particularly like this method, and am looking for an alternative
@@ -97,8 +102,8 @@ setBorderTransparency(number alpha)
Events:
```lua
mouseEnter
mouseExit
mouseEnter()
mouseExit()
```
### Frame class
@@ -117,6 +122,16 @@ setFontFace(string fontFile)
setTextSize(number size)
```
### Event class
Events provide a way for *listeners*, user-defined functions, to be called when certain things happen with JUI objects.
When an event is "connected", the function given will be called whenever this event is fired by JUI.
Methods:
```lua
number connect(function newConnection) -- returns a listenerID which can be used to disconnect the listener later
disconnect(number listenerID) -- disconnect the listener using the listenerID, so that it is no longer called
```
### Dimension datatype
Constructor:

View File

@@ -1,9 +1,8 @@
local DataType = require("classes/DataType")
local newclass = require("classes/YACI")
local Event = DataType:subclass("Event")
local Event = newclass("Event")
function Event:init()
self.super:init()
self.callbacks = {}
end