Class: Qt::KeyEvent
Overview
Make keystrokes events easier to work with. For Qt::Key_Whatever
events, KeyEvent instances will now respond to whatever?
Instance Method Summary collapse
-
#ctrl? ⇒ Boolean
is the control key pressed?.
- #key?(name) ⇒ Boolean
-
#method_missing(sym, *args, &block) ⇒ Object
Provide a shortcut for the Qt::Key_Whatever constants.
- #old_method_missing ⇒ Object
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
Provide a shortcut for the Qt::Key_Whatever constants. Just say event.whatever?
242 243 244 245 246 247 248 249 250 251 |
# File 'lib/qtext/extensions.rb', line 242 def method_missing( sym, *args, &block ) begin st = sym.to_s if st.chomp!( '?' ) key?( st ) else old_method_missing( sym, *args, &block ) end end end |
Instance Method Details
#ctrl? ⇒ Boolean
is the control key pressed?
235 236 237 |
# File 'lib/qtext/extensions.rb', line 235 def ctrl? modifiers & Qt::ControlModifier.to_i == Qt::ControlModifier.to_i end |
#key?(name) ⇒ Boolean
253 254 255 |
# File 'lib/qtext/extensions.rb', line 253 def key?( name ) key == eval( "Qt::Key_#{name.to_s.camelize}" ) end |
#old_method_missing ⇒ Object
239 |
# File 'lib/qtext/extensions.rb', line 239 alias_method :old_method_missing, :method_missing |