簡単な使い方
簡単な使い方
以下の手順で検索パネルを組み込むことができます。
(OgreKitプロジェクトのFind Pane TestやMy Find Panel Example、TextEditへの組み込み例も参照)
(1) InterfaceBuilderでMainMenu.xibを開き、 右図「OgreTextFinder.hの読み込み」のように、 XCodeのFrameworksグループ内にあるOgreKit.framework/Headers/OgreTextFinder.hをMainMenu.xibウィンドウにドロップしてください。
(2) 右図「OgreTextFinderのインスタンス化」のように、OgreTextFinderをインスタンス化し、MainMenu.xibを保存してください。
検索対象となるTextViewが常にmain windowのfirst responderである場合は、これだけで検索パネルが使用可能になります。もしそうでない場合(例えば、document windowにTextView以外にTextField等がある場合)は、(3)の作業で検索対象となるTextViewをOgreTextFinderに教えるコードを追加してください。
#import <OgreKit/OgreKit.h>
@interface MyDocument : NSDocument<OgreTextFindDataSource> {
IBOutlet NSTextView *textView;
...中略...
@end
@implementation MyDocument
- (void)tellMeTargetToFindIn:(id)textFinder
{
[textFinder setTargetToFindIn:textView];
}
...中略...
@end
4. ドキュメント・ベース・アプリケーションに検索パネルを組み込む
OgreTextFinder.hの読み込み
OgreTextFinderのインスタンス化