Difference between revisions of "EventDispatcher:dispatchEvent"
From GiderosMobile
Line 3: | Line 3: | ||
=== Description === | === Description === | ||
− | Dispatches an event to this | + | Dispatches an event to this '''EventDispatcher''' instance. |
− | |||
<source lang="lua"> | <source lang="lua"> | ||
EventDispatcher:dispatchEvent(event) | EventDispatcher:dispatchEvent(event) | ||
Line 10: | Line 9: | ||
=== Parameters === | === Parameters === | ||
− | '''event''': (Event) | + | '''event''': (Event) the '''Event''' object to be dispatched<br/> |
+ | |||
+ | === Example === | ||
+ | <source lang="lua"> | ||
+ | function ButtonTextP9UDDT:onMouseUp(e) | ||
+ | if self.focus and self.isclicked then | ||
+ | local ec = Event.new("clicked") | ||
+ | self:dispatchEvent(ec) -- button was clicked | ||
+ | e:stopPropagation() | ||
+ | end | ||
+ | self.focus = false | ||
+ | self.isclicked = false | ||
+ | self:updateVisualState() | ||
+ | end | ||
+ | </source> | ||
{{EventDispatcher}} | {{EventDispatcher}} |
Revision as of 10:00, 13 November 2022
Available since: Gideros 2011.6
Class: EventDispatcher
Description
Dispatches an event to this EventDispatcher instance.
EventDispatcher:dispatchEvent(event)
Parameters
event: (Event) the Event object to be dispatched
Example
function ButtonTextP9UDDT:onMouseUp(e)
if self.focus and self.isclicked then
local ec = Event.new("clicked")
self:dispatchEvent(ec) -- button was clicked
e:stopPropagation()
end
self.focus = false
self.isclicked = false
self:updateVisualState()
end