class Fox::FXPseudoTarget
FXPseudoTarget instances act as the message target for any widgets that elect to use the connect method to map certain message types to blocks.
Public Class Methods
new()
click to toggle source
Returns an initialized FXPseudoTarget object.
Calls superclass method
Fox::FXObject.new
# File lib/fox16/responder2.rb, line 22 def initialize super @context = {} end
Public Instance Methods
onHandleMsg(sender, sel, ptr)
click to toggle source
Handle a message from sender, with selector sel and message data ptr.
# File lib/fox16/responder2.rb, line 50 def onHandleMsg(sender, sel, ptr) message_type = Fox.FXSELTYPE(sel) ctx = @context[message_type] callable_object = ctx[:callable] params = ctx[:params] result = callable_object.call(sender, sel, ptr) case message_type when SEL_TIMEOUT if params[:repeat] FXApp.instance.addTimeout(params[:delay], callable_object, params) else @@targets_of_pending_timers.delete(self) end when SEL_CHORE if params[:repeat] FXApp.instance.addChore(callable_object, params) else @@targets_of_pending_chores.delete(self) end end result end
pconnect(message_type, callable_object, params={})
click to toggle source
Store an association between a message of type message_type with a callable object.
# File lib/fox16/responder2.rb, line 31 def pconnect(message_type, callable_object, params={}) @context[message_type] = { :callable => callable_object, :params => params } FXMAPTYPE(message_type, :onHandleMsg) case message_type when SEL_TIMEOUT @@targets_of_pending_timers[self] = self when SEL_CHORE @@targets_of_pending_chores[self] = self when SEL_SIGNAL @@targets_of_pending_signals[self] = self when SEL_IO_READ, SEL_IO_WRITE, SEL_IO_EXCEPT @@targets_of_pending_inputs[self] = self end end