Android Question Panel touch event with reflector (or GestureDetector)

vfafou

Well-Known Member
Licensed User
Longtime User
Hello!
I need to use a transparent panel and pass the touch event under this panel.
For this reason I use reflector with:
B4X:
Private r As Reflector
r.Target = pnlTouch
r.SetOnTouchListener("pnlTouch_MyTouch")
Logging the Action parameter, I see only 0 = ACTION_DOWN.
I additionally need to use the other 2 actions of the built-in touch event, ACTION_MOVE and ACTION_UP but they don't fire with reflector.
GestureDetector has exactly the same behaviour.
Is there any other approach to have a similar functionality?

Thank you in advance!
 

drgottjr

Expert
Licensed User
Longtime User
Is there any other approach to have a similar functionality?
do you mean is there some other approach that doesn't work like they don't work?
or do you mean you wanted something that fires on action_down, action_more, etc? because if that's what you want, just use the touch events generated by the panel. i use them; they all fire no problem: up, down, move, not move. what's with reflection? the panel's touch event is already, as you say, built in. what is it that you're doing that doesn't make it work?
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
Logging the Action parameter, I see only 0 = ACTION_DOWN
Are you sure? I am presently developing an app adding the event using identical code, but with a label, and there is no problem identifying the different actions.


what's with reflection? the panel's touch event is already, as you say, built in
Adding the event by reflection ensures that the event is called immediately. The built in touch events go via the message loop which delays them so if you are using the move actions to drag something around adding the event by reflection gives a smoother feel.
 
Upvote 0

vfafou

Well-Known Member
Licensed User
Longtime User
Hello @drgottjr!
Thank you for your response!
or do you mean you wanted something that fires on action_down, action_more, etc?
Yes, I need something that fires all actions available but via reflection, because I need to pass the event to the underlying view after executing some code before the Return False. For that reason it isn't usable the built-in event of the panel.
 
Upvote 0

vfafou

Well-Known Member
Licensed User
Longtime User
Are you sure? I am presently developing an app adding the event using identical code, but with a label, and there is no problem identifying the different actions.

Hello @agraham!
Thank you for your response!
Do you mean that instead of a panel you put a label and fire all actions?
If yes, then I will try it!
 
Upvote 0

vfafou

Well-Known Member
Licensed User
Longtime User
Yes, I am using it to drag drag labels around an Activity by touch to rearrange the layout. I don't see why it wouldn't work with any other view. Post a small project that illustrates the problem.
I have attached a fresh B4APages project with the same problem!
I think that I do something wrong...
 

Attachments

  • B4APagesP1.zip
    10 KB · Views: 282
Upvote 0

vfafou

Well-Known Member
Licensed User
Longtime User
Return True, not False in the Panel2_MyTouch event.
OK, by returning False I can’t move the underlying object, but I need the actions to control the visibility of an imageview on top of the layout!
If you want, I can send you screenshots to see what exactly I mean!
 
Upvote 0
Top