Class: Qt::RubySignalAction
- Includes:
- SignalActions
- Defined in:
- lib/qt_connect/qt_jbindings.rb
Overview
RubySignalAction is the Ruby class which implements the functionality to activate a Ruby Block or Object Method as a result of a Qt emitted Signal the Ruby method names match the names of the Java interface SignalActions: (see SignalActions.java)
Instance Attribute Summary collapse
-
#block ⇒ Object
Returns the value of attribute block.
-
#method ⇒ Object
Returns the value of attribute method.
-
#receiver ⇒ Object
Returns the value of attribute receiver.
Instance Method Summary collapse
- #append_args(*args) ⇒ Object
- #emit(a) ⇒ Object
-
#initialize(receiver = nil, method = nil, &block) ⇒ RubySignalAction
constructor
A new instance of RubySignalAction.
Constructor Details
#initialize(receiver = nil, method = nil, &block) ⇒ RubySignalAction
Returns a new instance of RubySignalAction.
184 185 186 187 188 189 190 |
# File 'lib/qt_connect/qt_jbindings.rb', line 184 def initialize(receiver=nil,method=nil,&block) super() @receiver=receiver @method=method @block=block @args=[] end |
Instance Attribute Details
#block ⇒ Object
Returns the value of attribute block.
183 184 185 |
# File 'lib/qt_connect/qt_jbindings.rb', line 183 def block @block end |
#method ⇒ Object
Returns the value of attribute method.
183 184 185 |
# File 'lib/qt_connect/qt_jbindings.rb', line 183 def method @method end |
#receiver ⇒ Object
Returns the value of attribute receiver.
183 184 185 |
# File 'lib/qt_connect/qt_jbindings.rb', line 183 def receiver @receiver end |
Instance Method Details
#append_args(*args) ⇒ Object
192 193 194 |
# File 'lib/qt_connect/qt_jbindings.rb', line 192 def append_args(*args) @args=args end |
#emit(a) ⇒ Object
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
# File 'lib/qt_connect/qt_jbindings.rb', line 206 def emit(a) args=a+@args n=nil if @method && (md=@method.to_s.match(/([0-9]*)(.+)/x)) #?????????????????? n=md[1].to_i unless md[1]=='' @method=md[2].gsub('()','').to_sym end if (m=args.size)>0 @block.call(*args) if @block if @receiver && @method #cap the number of arguments to number wanted by receiver #e.g. triggered uses signal1 iso signal0 as in example n ||=@receiver.method(@method).arity if (n==0) @receiver.send(@method) else args.slice!(0,n) if (m>n) && (n>0) @receiver.send(@method,*args) end end else @block.call if @block @receiver.send(@method) if @receiver && @method end end |