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?
237 238 239 240 241 242 243 244 245 246 247 |
# File 'lib/qtext/extensions.rb', line 237 def method_missing( sym, *args, &block ) begin if sym.to_s[-1] == "?"[0] key?( sym.to_s[0..-2] ) else old_method_missing( sym, *args, &block ) end rescue Exception => e old_method_missing( sym, *args, &block ) end end |
Instance Method Details
#ctrl? ⇒ Boolean
is the control key pressed?
230 231 232 |
# File 'lib/qtext/extensions.rb', line 230 def ctrl? modifiers & Qt::ControlModifier.to_i == Qt::ControlModifier.to_i end |
#key?(name) ⇒ Boolean
249 250 251 |
# File 'lib/qtext/extensions.rb', line 249 def key?( name ) key == eval( "Qt::Key_#{name.to_s.camelize}" ) end |
#old_method_missing ⇒ Object
234 |
# File 'lib/qtext/extensions.rb', line 234 alias_method :old_method_missing, :method_missing |