| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
For some time, I've been looking into getting tablet events in Java, and from looking at the archives, I see that there are quite a few other people interested in the same thing. I have a solution which works for Java 1.4 onwards and I'm posting it in case it might be useful to someone. The idea is to use JNI to override the NSApplication's sendEvent method using poseAs. This lets us see every event which gets dispatched. In the code below I just stuff the pressure information into a static variable, but you could do more sophisticated things. The code is fairly obvious. Comments (but not flames) are welcome. static float pressure; @interface TabletHackApplication : NSApplication @end @implementation TabletHackApplication - (void) sendEvent:(NSEvent *)event { switch ( [event type] ) { case NSLeftMouseDown: case NSLeftMouseUp: case NSLeftMouseDragged: pressure = [event pressure]; break; default: break; } [super sendEvent: event]; } @end JNIEXPORT void JNICALL Java_TabletHack_initialize(JNIEnv *env, jobject this) { class_poseAs([TabletHackApplication class], [NSApplication class]); } JNIEXPORT jfloat JNICALL Java_TabletHack_getPressure(JNIEnv *env, jobject this) { return pressure; } Jerry |
_______________________________________________ Do not post admin requests to the list. They will be ignored. Java-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/java-dev/email@hidden This email sent to email@hidden
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.