Hey guys,
first of all, Im trying to access the
@Override
public boolean onTouchEvent(MotionEvent event) {
...
for Android. This normally belongs into a MainActivity Java File, which I have no access to through a usual Uno instance.
Ive tried to put it into a uno file and wrap it as a foreign code event method, but it is not touched at all.
Is there a way to append that event to any View element and generate a new View element?
And if its also not possible to wrap that method in any way into an instance or something like that of the running MainActivity?
Is there a way through the uno api to determine if a touch on the View occured and extract the coordinates of it?
Thanks for replies
Benny
Hi!
You can make a Native UI Component and use an OnViewTouchListener
(which is essentially the same as overriding onTouchEvent
)
For example:
extern(Android) public class InputView : LeafView
{
public InputView() : base(Create())
{
InstallOnTouchListener(Handle);
}
[Foreign(Language.Java)]
static Java.Object Create()
@{
return new android.view.View(@(Activity.Package).@(Activity.Name).GetRootActivity());
@}
bool OnTouch(Java.Object view, Java.Object motionEvent)
{
return false;
}
[Foreign(Language.Java)]
void InstallOnTouchListener(Java.Object handle)
@{
((android.view.View)handle).setOnTouchListener(new android.view.View.OnTouchListener() {
public boolean onTouch(android.view.View v, android.view.MotionEvent event) {
return @{InputView:Of(_this).OnTouch(Java.Object,Java.Object):Call(v,event)};
}
});
@}
}