[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[pde-dev] Getting Tablet Events (in OS X)
|
hello,
i'm new to the list. i have a problem: i have using jerry huxtable's
JNITablet ( http://www.jhlabs.com/java/tablet/ ) successfully for a
long time now. i am now writing an Eclipse application in Scala,
using my Java libraries. the code in JNITablet doesn't work any more
because as it seems there is a stupidity that only one instance of
NSApplication can exist and that has a non-plugable method sendEvent
that is for mouse and tablet event notifications.
the approach of JNITablet is a follows: via JNI a call to startup is
made which instantiates a fake-subclass of NSApplication, using some
method named poseAsClass:
JNIEXPORT void JNICALL Java_com_jhlabs_jnitablet_TabletWrapper_startup
(JNIEnv *env, jobject this) {
[CustomApplication poseAsClass: [NSApplication class]];
g_object = (*env)->NewGlobalRef( env, this );
g_class = (*env)->GetObjectClass( env, this );
g_class = (*env)->NewGlobalRef( env, g_class );
if( g_class != (jclass) 0 ) {
g_postMethodID = (*env)->GetMethodID( env, g_class,
"postEvent", "(IIFFIIIIIFFFFFSSS)V" );
g_postProximityMethodID = (*env)->GetMethodID( env, g_class,
"postProximityEvent", "(IIZIIIIIIII)V" );
} else {
NSLog(@"JNITablet: Couldn't register java methods");
}
}
this CustomApplication is as follows
@interface CustomApplication : NSApplication
@end
@implementation CustomApplication
- (void) sendEvent:(NSEvent *)event
{
JNIEnv *env;
bool shouldDetach = false;
int clickCount = -1;
switch ( [event type] ) {
case NSLeftMouseDown:
case NSLeftMouseUp:
clickCount = [event clickCount];
case NSMouseMoved:
case NSLeftMouseDragged:
case NSTabletPoint:
// ...
// ... here's the code that calls back into the Java VM
// ...
}
[super sendEvent: event];
}
@end
as it turns out, now that my java code is running inside an eclipse
application, CustomApplication's sendEvent is not called any more,
hence i don't receive the tablet events. second problem is, i'm a
java developer with barely any knowledge of: ObjectiveC, Cocoa, ....
(and unfortunately, also SWT, as all my code is in Swing, using the
SWT-to-Swing bridge)
so.... any hints are welcome as how i an reestablish my tablet event
delivery...
thanks a lot!
ciao, -sciss-