Top Level Namespace
Defined Under Namespace
Modules: Cucumber, FeaturesHelper, Gtk, Gutkumber
Instance Method Summary
collapse
Instance Method Details
#inspect_event_key(gdk_event_key) ⇒ Object
38
39
40
41
42
43
44
45
|
# File 'lib/gutkumber/steps/keypress_steps.rb', line 38
def inspect_event_key(gdk_event_key)
kv = gdk_event_key.keyval
ks = gdk_event_key.state - Gdk::Window::MOD2_MASK
ks = ks - Gdk::Window::MOD4_MASK
key = Gtk::Accelerator.get_label(kv, ks)
return kv, ks, key
end
|
#left_click_on(widget) ⇒ Object
26
27
28
29
30
31
32
|
# File 'lib/gutkumber/steps/clicking_steps.rb', line 26
def left_click_on(widget)
allocation = widget.allocation
x = allocation.x + allocation.width/2
y = allocation.y + allocation.height/2
make_event_button(widget.window, x, y, 1, :press).put
make_event_button(widget.window, x, y, 1, :release).put
end
|
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/gutkumber/steps/clicking_steps.rb', line 2
def make_event_button(window, x, y, button, type)
case type
when :press
event_button = Gdk::EventButton.new(Gdk::Event::BUTTON_PRESS)
when :press2
event_button = Gdk::EventButton.new(Gdk::Event::BUTTON2_PRESS)
when :press3
event_button = Gdk::EventButton.new(Gdk::Event::BUTTON3_PRESS)
when :release
event_button = Gdk::EventButton.new(Gdk::Event::BUTTON_RELEASE)
end
event_button.x = x
event_button.y = y
event_button.button = button
event_button.time = Gdk::Event::CURRENT_TIME
event_button.window = window
event_button
end
|
#make_event_key(key, type) ⇒ Object
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/gutkumber/steps/keypress_steps.rb', line 2
def make_event_key(key, type)
bits = key.split("+")
ctrl = (bits.include?("Ctrl") ? true : false)
alt = (bits.include?("Alt") ? true : false)
supr = (bits.include?("Super") ? true : false)
letter = bits.last
shift = (bits.include?("Shift") && (letter =~ /^[[:alpha:]]$/ or letter.length > 1)? true : false)
case type
when :release
new_event_key = Gdk::EventKey.new(Gdk::Event::KEY_RELEASE)
when :press
new_event_key = Gdk::EventKey.new(Gdk::Event::KEY_PRESS)
end
new_mod_mask = 0
new_mod_mask |= Gdk::Window::ModifierType::SHIFT_MASK if shift
new_mod_mask |= Gdk::Window::ModifierType::CONTROL_MASK if ctrl
new_mod_mask |= Gdk::Window::ModifierType::MOD1_MASK if alt
new_mod_mask |= Gdk::Window::ModifierType::SUPER_MASK if supr
new_mod_mask = Gdk::Window::ModifierType.new(new_mod_mask)
new_event_key.state = new_mod_mask
if letter.length > 1
keyval = Gdk::Keyval.from_name(letter)
if keyval == 0
keyval = Gdk::Keyval.from_name(letter.downcase)
end
else
keyval = letter[0]
end
new_event_key.keyval = keyval
new_event_key.hardware_keycode = Gdk::Keymap.default.get_entries_for_keyval(keyval).first.first
new_event_key.window = Gtk::Window.toplevels.first.window
new_event_key
end
|
2
3
4
5
6
|
# File 'lib/gutkumber/steps/menu_steps.rb', line 2
def
= []
ObjectSpace.each_object(Gtk::Menu) { |m| << m if m.visible? }
end
|
#press_key(key) ⇒ Object
47
48
49
50
|
# File 'lib/gutkumber/steps/keypress_steps.rb', line 47
def press_key(key)
make_event_key(key, :press).put
make_event_key(key, :release).put
end
|
#right_click_on(widget) ⇒ Object
21
22
23
24
|
# File 'lib/gutkumber/steps/clicking_steps.rb', line 21
def right_click_on(widget)
make_event_button(widget.window, 0, 0, 3, :press).put
make_event_button(widget.window, 0, 0, 3, :release).put
end
|