Android Question [Solved] Message: raiseEvent for snack_touch returned null

asales

Expert
Licensed User
Longtime User
I want to create a view with a panel and a button to show as a warning in the screen bottom (a snack).

I use this code below to avoid a click in the panel and raises the event of the components under the panel.
B4X:
Dim r As Reflector
r.Target = views.pnl
r.SetOnTouchListener("Snack_Touch")

Works, but it shows this message in the logs:
raiseEvent for snack_touch returned null
It's an error? How can I fix it?

Thanks in advance for any tips.
 
Solution
Actually the return from an OnTouchListener should be a boolean that if True indicates that the listener has handled the event and doesn't want it propagated further to other views in the event chain. If it returns False then it tells Android to let the next listener in the event chain to be called. When I wrote the Reflection library I opted to check for this and log a warning. After the warning the Reflection OnTouchListener actually returns True to indicate that event was consumed.

To remove the warning declare Snack_Touch as returning a Boolean and return True. This is explained in the Intellisense comments for SetOnTouchListener.

drgottjr

Expert
Licensed User
Longtime User
it's looking for the touch indicator (up,down,etc) derived from the listener.
it seems to take into account that there may be no such indicator, in which
case it posts that message. it then consumes the even and exits.
no harm, no foul. you can check it out in the reflection.jar in the b4a internal
libs.
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
Actually the return from an OnTouchListener should be a boolean that if True indicates that the listener has handled the event and doesn't want it propagated further to other views in the event chain. If it returns False then it tells Android to let the next listener in the event chain to be called. When I wrote the Reflection library I opted to check for this and log a warning. After the warning the Reflection OnTouchListener actually returns True to indicate that event was consumed.

To remove the warning declare Snack_Touch as returning a Boolean and return True. This is explained in the Intellisense comments for SetOnTouchListener.
 
Last edited:
Upvote 1
Solution
Top