osxhotkey 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/Rakefile +3 -2
  2. data/lib/osx/hotkey.rb +23 -12
  3. metadata +3 -3
data/Rakefile CHANGED
@@ -15,7 +15,7 @@ DESCRIPTION = "HotKey integration with Ruby/Cocoa"
15
15
  RUBYFORGE_PROJECT = "osxhotkey"
16
16
  HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
17
17
  BIN_FILES = %w( )
18
- VERS = "0.0.2"
18
+ VERS = "0.0.3"
19
19
 
20
20
 
21
21
  NAME = "osxhotkey"
@@ -90,7 +90,8 @@ end
90
90
  Rake::RDocTask.new do |rdoc|
91
91
  rdoc.rdoc_dir = 'html'
92
92
  rdoc.options += RDOC_OPTS
93
- rdoc.template = "#{ENV['template']}.rb" if ENV['template']
93
+ #rdoc.template = "#{ENV['template']}.rb" if ENV['template']
94
+ rdoc.template = "#{ENV["HOME"]}/coderepos/lang/ruby/rdoc/generators/template/html/resh/resh.rb"
94
95
  if ENV['DOC_FILES']
95
96
  rdoc.rdoc_files.include(ENV['DOC_FILES'].split(/,\s*/))
96
97
  else
data/lib/osx/hotkey.rb CHANGED
@@ -8,7 +8,7 @@ include OSX
8
8
 
9
9
  class OSX::NSApplicationWithHotKey < NSApplication
10
10
 
11
- ns_override 'sendEvent:'
11
+ # ns_override 'sendEvent:'
12
12
 
13
13
  KEYMAP = {
14
14
  "0" => 0x1D, "1" => 0x12, "2" => 0x13, "3" => 0x14,
@@ -20,6 +20,10 @@ class OSX::NSApplicationWithHotKey < NSApplication
20
20
  "O" => 0x1F, "P" => 0x23, "Q" => 0x0C, "R" => 0x0F,
21
21
  "S" => 0x01, "T" => 0x11, "U" => 0x20, "V" => 0x09,
22
22
  "W" => 0x0D, "X" => 0x07, "Y" => 0x10, "Z" => 0x06,
23
+ "=" => 0x18, "-" => 0x1B, "]" => 0x1E, "[" => 0x21,
24
+ "RET" => 0x24, "\"" => 0x27, ";" => 0x29, "\\" => 0x2A,
25
+ "," => 0x2B, "/" => 0x2C, "." => 0x2F, "TAB" => 0x30,
26
+ "SPC" => 0x31, "`" => 0x32, "BS" => 0x33, "ESC" => 0x35,
23
27
  }
24
28
 
25
29
  def sendEvent(event) # :nodoc:
@@ -41,20 +45,24 @@ class OSX::NSApplicationWithHotKey < NSApplication
41
45
  raise ArgumentError, "Require block." unless block_given?
42
46
  mod = 0
43
47
  key = nil
44
- keys.split('+').each do |k|
45
- k = k.upcase
46
- case k
47
- when 'SHIFT', 'CONTROL', 'COMMAND', 'OPTION'
48
- mod |= HotKey.const_get(k)
49
- else
50
- if KEYMAP[k]
51
- key = KEYMAP[k]
48
+ if keys.kind_of? Numeric
49
+ key = keys
50
+ else
51
+ keys.split('+').each do |k|
52
+ k = k.upcase
53
+ case k
54
+ when 'SHIFT', 'CONTROL', 'COMMAND', 'OPTION'
55
+ mod |= HotKey.const_get(k)
52
56
  else
53
- raise ArgumentError, "The Key #{k} is not in Map"
57
+ if KEYMAP[k]
58
+ key = KEYMAP[k]
59
+ else
60
+ raise ArgumentError, "The Key #{k} is not in Map"
61
+ end
54
62
  end
55
63
  end
64
+ raise ArgumentError, "The Key is invalid" unless key
56
65
  end
57
- raise ArgumentError, "The Key is invalid" unless key
58
66
  ref = HotKey.new(key, mod)
59
67
  id = ref.register
60
68
  @hotkey_procs ||= {}
@@ -66,7 +74,10 @@ end
66
74
 
67
75
  if $0 == __FILE__
68
76
  app = NSApplicationWithHotKey.sharedApplication
69
- ref = app.register_hotkey("command+shift+j") do
77
+ # ref = app.register_hotkey("command+shift+j") do
78
+ # puts 'hello'
79
+ # end
80
+ ref = app.register_hotkey("command+`") do
70
81
  puts 'hello'
71
82
  end
72
83
 
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.0
2
+ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: osxhotkey
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.2
7
- date: 2006-11-19 00:00:00 +09:00
6
+ version: 0.0.3
7
+ date: 2007-10-26 00:00:00 +09:00
8
8
  summary: HotKey integration with Ruby/Cocoa
9
9
  require_paths:
10
10
  - lib