Class: Event

Inherits:
Object
  • Object
show all
Defined in:
lib/rum/mac/keyboard_hook.rb

Instance Method Summary collapse

Instance Method Details

#down?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/rum/mac/keyboard_hook.rb', line 41

def down?
  down != 0
end

#get_flagsObject



69
70
71
# File 'lib/rum/mac/keyboard_hook.rb', line 69

def get_flags
  CGEventGetFlags(eventRef)
end

#get_integer_value_field(field) ⇒ Object



61
62
63
# File 'lib/rum/mac/keyboard_hook.rb', line 61

def get_integer_value_field(field)
  CGEventGetIntegerValueField(eventRef, field)
end

#get_user_dataObject



65
66
67
# File 'lib/rum/mac/keyboard_hook.rb', line 65

def get_user_data
  CGEventGetIntegerValueField(eventRef, KCGEventSourceUnixProcessID)
end

#idObject



49
50
51
# File 'lib/rum/mac/keyboard_hook.rb', line 49

def id
  get_integer_value_field(KCGKeyboardEventKeycode)
end

#keycodeObject



45
46
47
# File 'lib/rum/mac/keyboard_hook.rb', line 45

def keycode
  get_integer_value_field(KCGKeyboardEventKeycode)
end

#set_event_source(source) ⇒ Object



33
34
35
# File 'lib/rum/mac/keyboard_hook.rb', line 33

def set_event_source(source)
  CGEventSetSource(eventRef, source)
end

#set_flags(flags) ⇒ Object



73
74
75
# File 'lib/rum/mac/keyboard_hook.rb', line 73

def set_flags(flags)
  CGEventSetFlags(eventRef, flags)
end

#set_integer_value_field(field, value) ⇒ Object



57
58
59
# File 'lib/rum/mac/keyboard_hook.rb', line 57

def set_integer_value_field(field, value)
  CGEventSetIntegerValueField(eventRef, field, value)
end

#set_keycode(code) ⇒ Object



37
38
39
# File 'lib/rum/mac/keyboard_hook.rb', line 37

def set_keycode(code)
  set_integer_value_field(KCGKeyboardEventKeycode, code)
end

#to_sObject



53
54
55
# File 'lib/rum/mac/keyboard_hook.rb', line 53

def to_s
  "#{down? ? 'Down' : 'Up'}: Id #{id}"
end