Class: Fox::FXPseudoKeyboard

Inherits:
Object
  • Object
show all
Defined in:
lib/fox16/pseudokeyboard.rb

Overview

An FXPseudoKeyboard object provides a simple means to operate widgets programmatically, to aid test driven design. An FXPseudoKeyboard instance can be pointed at an FXObject and will manage the sending of events to it.

For example:

textfield = FXTextField.new(...)
pk = FXPseudoKeyboard.new(textfield)
pk.doKeyPress     # sends a SEL_KEYPRESS message to the textfield
pk.doKeyRelease   # sends a SEL_KEYRELEASE message to the textfield

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tgt = nil) ⇒ FXPseudoKeyboard

Returns a new instance of FXPseudoKeyboard.



19
20
21
# File 'lib/fox16/pseudokeyboard.rb', line 19

def initialize(tgt=nil)
  @target = tgt
end

Instance Attribute Details

#targetObject

Returns the value of attribute target.



17
18
19
# File 'lib/fox16/pseudokeyboard.rb', line 17

def target
  @target
end

Instance Method Details

#doKeyPressObject



23
24
25
26
27
28
29
# File 'lib/fox16/pseudokeyboard.rb', line 23

def doKeyPress
  unless @target.nil?
    evt = FXEvent.new
    evt.type = Fox::SEL_KEYPRESS
    @target.handle(self, Fox.FXSEL(Fox::SEL_KEYPRESS, 0), evt)
  end
end

#doKeyReleaseObject



31
32
33
34
35
36
37
# File 'lib/fox16/pseudokeyboard.rb', line 31

def doKeyRelease
  unless @target.nil?
    evt = FXEvent.new
    evt.type = Fox::SEL_KEYRELEASE
    @target.handle(self, Fox.FXSEL(Fox::SEL_KEYRELEASE, 0), evt)
  end
end