Hi, I'm currently programming an interface between some C++ code and Java using JNI.
I'm getting some events in my GUI that I want to pass to a C++ event handler.
I therefore call a function that I wrote in Java.
public void sendToEventQueue( AWTEvent evt ) {
Mudkiptz.Main.fctC_sendEvent( evt );
}
This method is in an abstract class EventHdl that I used as a super class for keyEventHandler in which I overload the keyTyped( KeyEvent) to send the KeyEvent to my C++ event handler with the method previously declared.
My problem is that I want to get my keyEvent keyCode from the KeyEvent that I passed.
JNIEXPORT void JNICALL Java_Mudkiptz_Main_fctC_1sendEvent
(JNIEnv* env, jclass, jobject evt) {
// Obtenir les infos (Get information)
jclass keyEventClass = env->FindClass("java/awt/event/KeyEvent");
if( env->IsInstanceOf(evt, keyEventClass) ) {
jmethodID getKeyCode = env->GetMethodID(keyEventClass, "getKeyCode", "()I");
int keyCode = 0;
keyCode = env->CallIntMethod(evt, getKeyCode);
}
// getInstance()
Application::obtenirInstance()->getEventQueue()->push( evt );
}
But it doesn't not work... :( I'm not used to JNI so it may be a easy mistake nevertheless I would really appreciate help.
Edit: I should have been more precise. The method return but keyCode always equals zero when it should give the keyCode. thanks!
Thanks!