Log in or register to post comments

how to change Virtual Buttons action?

June 20, 2012 - 3:57am #1

Hello
Im using the VirtualButoons sample code.
i want to change the isPressed action, so the button name will displayed to the screen.

i tried to do that by changing the renderFrame function in virtuslButttons.cpp
to this code:

if (button->isPressed())
  {
  
	jstring js = env->NewStringUTF(button->getName());
	jclass javaClass = env->GetObjectClass(obj);
	jmethodID method = env->GetMethodID(javaClass, "displayMessage", "(Ljava/lang/String;)V");
	env->CallVoidMethod(obj, method, js);

    }  

however,
when pressing buttons a message appear but stay for long time,
even after "releasing the button.

what did i do wrong?

how to change Virtual Buttons action?

June 21, 2012 - 8:50am #2

I think that you'll need to clear the displayMessage value when button->isPressed() is false.

if (button->isPressed()) { jstring js = env->NewStringUTF(button->getName()); jclass javaClass = env->GetObjectClass(obj); jmethodID method = env->GetMethodID(javaClass, "displayMessage", "(Ljava/lang/String;)V"); env->CallVoidMethod(obj, method, js); }else{ jstring js = env->NewStringUTF(""); jclass javaClass = env->GetObjectClass(obj); jmethodID method = env->GetMethodID(javaClass, "displayMessage", "(Ljava/lang/String;)V"); env->CallVoidMethod(obj, method, js) }

Log in or register to post comments