Class: Context::Gtk::Key
- Inherits:
-
Key
show all
- Defined in:
- lib/Context/Gtk/Key.rb
Instance Attribute Summary
Attributes inherited from Key
#character, #modifier
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Key
#eql?, #hash, #initialize, null, #null?
Constructor Details
This class inherits a constructor from Context::Key
Class Method Details
.createFromGtkEvent(event) ⇒ Object
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/Context/Gtk/Key.rb', line 36
def Key::createFromGtkEvent(event)
modifier = getModifierFromEvent(event)
character = getCharacterFromEvent(event)
if((modifier != Context::Key::Modifier::ERROR) &&
(!character.nil?))
Key.new(modifier, character)
else
Key.null
end
end
|
.getCharacterFromEvent(event) ⇒ Object
28
29
30
|
# File 'lib/Context/Gtk/Key.rb', line 28
def Key::getCharacterFromEvent(event)
Gdk::Keyval::to_name(event.keyval)
end
|
.getModifierFromEvent(event) ⇒ Object
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/Context/Gtk/Key.rb', line 8
def Key::getModifierFromEvent(event)
case event.state
when 0
Context::Key::Modifier::NONE
when Gdk::Window::CONTROL_MASK
Context::Key::Modifier::CONTROL
else
Context::Key::Modifier::ERROR
end
end
|
Instance Method Details
#createGtkEvent ⇒ Object
47
48
49
50
51
52
|
# File 'lib/Context/Gtk/Key.rb', line 47
def createGtkEvent
event = Gdk::EventKey.new(Gdk::Event::KEY_PRESS)
event.set_state(getGtkState)
event.set_keyval(getGtkKeyval)
event
end
|
#getGtkKeyval ⇒ Object
32
33
34
|
# File 'lib/Context/Gtk/Key.rb', line 32
def getGtkKeyval
Gdk::Keyval::from_name(@character)
end
|
#getGtkState ⇒ Object
19
20
21
22
23
24
25
26
|
# File 'lib/Context/Gtk/Key.rb', line 19
def getGtkState
case @modifier
when Context::Key::Modifier::CONTROL
Gdk::Window::CONTROL_MASK
else
0
end
end
|