Class: Fox::FXPseudoTarget
- Inherits:
-
FXObject
- Object
- FXObject
- Fox::FXPseudoTarget
- Includes:
- Responder
- Defined in:
- lib/fox16/responder2.rb
Overview
FXPseudoTarget instances act as the message target for any widgets that elect to use the #connect method to map certain message types to blocks.
Constant Summary
- @@targets_of_pending_timers =
{}
- @@targets_of_pending_chores =
{}
- @@targets_of_pending_signals =
{}
- @@targets_of_pending_inputs =
{}
Instance Method Summary (collapse)
-
- (FXPseudoTarget) initialize
constructor
Returns an initialized FXPseudoTarget object.
-
- (Object) onHandleMsg(sender, sel, ptr)
Handle a message from sender, with selector sel and message data ptr.
-
- (Object) pconnect(message_type, callable_object, params = {})
Store an association between a message of type message_type with a callable object.
Methods included from Responder
#FXMAPFUNC, #FXMAPFUNCS, #FXMAPTYPE, #FXMAPTYPES, #addMapEntry, #assocIndex, #identifier, #messageMap
Methods inherited from FXObject
Constructor Details
- (FXPseudoTarget) initialize
Returns an initialized FXPseudoTarget object.
22 23 24 25 |
# File 'lib/fox16/responder2.rb', line 22 def initialize super @context = {} end |
Instance Method Details
- (Object) onHandleMsg(sender, sel, ptr)
Handle a message from sender, with selector sel and message data ptr.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/fox16/responder2.rb', line 50 def onHandleMsg(sender, sel, ptr) = Fox.FXSELTYPE(sel) ctx = @context[] callable_object = ctx[:callable] params = ctx[:params] result = callable_object.call(sender, sel, ptr) case 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 |
- (Object) pconnect(message_type, callable_object, params = {})
Store an association between a message of type message_type with a callable object.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/fox16/responder2.rb', line 31 def pconnect(, callable_object, params={}) @context[] = { :callable => callable_object, :params => params } FXMAPTYPE(, :onHandleMsg) case 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 |