Apple Developer Connection
Advanced Search
Member Login Log In | Not a Member? Contact ADC

< Previous PageNext Page >

sendEventメソッドをオーバーライドする

この例ではNSApplicationをサブクラス化していることを思い出してください。sendEvent:メソッドをオーバーライドして、フルスクリーンのOpenGLコンテキストが画面上に存在する間、ユーザイベントを確実に処理できるようにするためです。Listing 5-5sendEvent:メソッドは、以下を確認します。

注:  Listing 5-5から#defineステートメントを、Xcodeプロジェクトにコピー&ペーストしないでください。コード例で使用している書式では、コードはコンパイルできません。代わりに、Max OS X v10.4デベロッパツールに付属しているPlayerの完全なXcodeプロジェクトを使用してください。詳細については、“Playerサンプルプロジェクトをビルドして実行する”を参照してください。

Listing 5-5  オーバーライドされたイベント送信メソッド

#define kRendererEventMask (NSLeftMouseDownMask|NSLeftMouseDraggedMask |
                    NSLeftMouseUpMask | NSRightMouseDownMask |
                    NSRightMouseDraggedMask | NSRightMouseUpMask |
                    NSOtherMouseDownMask | NSOtherMouseUpMask |
                    NSOtherMouseDraggedMask | NSKeyDownMask |
                    NSKeyUpMask | NSFlagsChangedMask |
                    NSScrollWheelMask)
 
- (void) sendEvent:(NSEvent*)event
{
    if(([event type] == NSKeyDown) && ([event keyCode] == 0x35))
            [NSApp terminate:nil];
 
    if(_renderer && (NSEventMaskFromType ([event type]) &
                 kRendererEventMask))
            [self renderWithEvent:event];
    else
    [       super sendEvent:event];
}


< Previous PageNext Page >


Last updated: 2006-12-05




Did this document help you?
Yes: Tell us what works for you.

It’s good, but: Report typos, inaccuracies, and so forth.

It wasn’t helpful: Tell us what would have helped.
Get information on Apple products.
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Copyright © 2007 Apple Inc.
All rights reserved. | Terms of use | Privacy Notice