B4A Library [Lib] Generic Motion Event

I've compiled it. :)

Erel's original post:
gme.png



Original quote:
Erel said:
You can handle the onGenericMotionEvent by following these steps:
1. Add the following class to your library:
B4X:
package anywheresoftware.b4a.objects;

import android.app.Activity;
import android.view.MotionEvent;
import anywheresoftware.b4a.BA;public class ActivityEx extends Activity {

@Overridepublic boolean onGenericMotionEvent(MotionEvent event) {try {
BA ba = (BA) this.getClass().getField("processBA").get(null);
ba.raiseEvent(null, "activity_ongenericmotionevent", event);returntrue;} catch (Exception e) {
throw new RuntimeException(e);
}
}
[USER=69643]@override[/USER]
public void onUserInteraction() {
super.onUserInteraction();
try {
BA ba = (BA) this.getClass().getField("processBA").get(null);
ba.raiseEvent2(null,true, "activity_onuserinteraction", false);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}

Add the following line to your activity:
B4X:
#Extends: anywheresoftware.b4a.objects.ActivityEx

And handle the events in your code:
B4X:
Sub Activity_OnUserInteractionLog("OnUserInteraction")End SubSub Activity_OnGenericMotionEvent(eventAs Object)Log(event)End Sub
The OnUserInteraction is just an example. You can remove it.
 

Attachments

  • LIB - Generic Motion Event.zip
    5.6 KB · Views: 393
Last edited:
Top