Hotkeyslib3 Cocoaでホットキー

Preview:

DESCRIPTION

2006-07-29 Cocoa勉強会 #19

Citation preview

HotKeysLib3Cocoaでホットキー

Cocoa勉強会�#19�/�2006.07.29�(土)�/�⽊村渡

Powered by Rabbit 0.6.3 and COZMIXNG

ホットキーとは?前⾯でないアプリにキーイベントを送る

ランチャーなどでよく利用されている

1/16

よくある質問

Q. ホットキーを使うには?

A. CarbonEventを使う

RegisterEventHotKey(), UnregisterEventHotKey() ほかいろいろ

2/16

Carbon お断り

そこでHotKeysLib3Cocoaのラッパー

ライセンスは�AS IS

作:�Rogue Amoeba Software

Audio HijackやNicecastの開発元

キー設定用のパネル付き(英独仏 ⽇?)

4/16

構成�(1)�キーの利用

PTKeyCombo

キーコンビネーション

PTHotKey

PTKeyComboとその動作の対応

PTHotKeyCenter

PTHotKeyを管理

5/16

構成�(2)�設定パネル

PTKeyComboPanel

設定パネル

6/16

ホットキーの登録PTKeyComboを⽣成1.�

PTHotKeyを⽣成2.�

PTKeyComboと対応する動作(ターゲット・アクション)をPTHotKeyに指定

3.�

PTHotKeyCenterにPTHotKeyを登録4.�

7/16

PTKeyComboキーと修飾キーを指定して⽣成

 +keyComboWithKeyCode:modifiers:plistを利用したインターフェイス -initWithPlistRepresentation: -plistRepresentation表⽰用の⽂字表現("^A"など) -description

8/16

PTHotKeyインスタンスの⽣成

 -initWithIdentifier:keyCombo:動作の設定

 -setTarget: -setAction:identifierは

PTHotKeyCenterで利用

アプリケーション内で⼀意になるように

9/16

PTHotKeyCenterインスタンスの取得

 +sharedCenterPTHotKeyの登録・登録解除 -registerHotKey: -unregisterHotKey:登録されているPTHotKeyの取得 -hotKeyWithIdentifier:

10/16

PTKeyComboPanelNSWindowControllerのサブクラス

インスタンスの取得

 +sharedPanelパネルを表⽰して、キーコンビネーションを設定する

 -runModalForHotKey:

11/16

PTKeyComboPaneldelegateスタイルでのシート呼び出し -runSheetForModalWindow:target:delegateメソッド -hotKeySheetDidEndWithReturnCode:設定されたキーコンビネーションの取得

 -keyCombo

12/16

ワナ設定パネルで記号の表⽰⽂字がちがう気がする…JISキーボード未対応?

通常のアクションと異なり、PTHotKeyのアクション実⾏時にはresponder chainをたぐらない

コンパイルするとPTKeyCombo.mでエラー。"NSTLocalizedString()"という関数がないと⾔われる。NSLocalizedString()にすればよい。

13/16

まだ調べてないことキーが重複したときってエラーになる?

14/16

おまけKey Code.appでキーコードを調べる

というか、キーの定数とかないのか?

15/16

おしまい質問などあればどうぞ

Powered by Rabbit 0.6.3 and COZMIXNG

16/16

Recommended