Difference between revisions of "EventDispatcher:dispatchEvent"

From GiderosMobile
m (Text replacement - "</source>" to "</syntaxhighlight>")
 
(One intermediate revision by the same user not shown)
Line 4: Line 4:
 
=== Description ===
 
=== Description ===
 
Dispatches an event to this '''EventDispatcher''' instance.
 
Dispatches an event to this '''EventDispatcher''' instance.
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
EventDispatcher:dispatchEvent(event)
 
EventDispatcher:dispatchEvent(event)
</source>
+
</syntaxhighlight>
  
 
=== Parameters ===
 
=== Parameters ===
Line 12: Line 12:
  
 
=== Example ===
 
=== Example ===
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
function ButtonTextP9UDDT:onMouseUp(e)
 
function ButtonTextP9UDDT:onMouseUp(e)
 
if self.focus and self.isclicked then
 
if self.focus and self.isclicked then
Line 23: Line 23:
 
self:updateVisualState()
 
self:updateVisualState()
 
end
 
end
</source>
+
</syntaxhighlight>
  
 
{{EventDispatcher}}
 
{{EventDispatcher}}

Latest revision as of 14:26, 13 July 2023

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