Android Question Pass click through transparent panel area

pauleffect

Member
Licensed User
Longtime User
Hello!
I'm trying to build an Ui that relies heavily on circles. A sample attached.

sample.png
sample.png


My problem is clicking on those rounded buttons or... anywhere else for that matter. Is there any way for me to ignore the reddish zones which, in the ui are fully transparent, of course.

so, when one was to click in the "top reddish corner", he would, instead, click on the button beneath it.

the getpixel approach isn't the best as the design relies on percentages, fluid layouts...
Thank you.

Edit: I think I can limp with the math and determine the bounds of each shape, so on and so fourth.

So... it really comes down to this:

if(not reddish) -> do button 1
else return false -> pass to the one beneath
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
I mean that you can handle the Touch event of the front most panel. Then if you want to pass it to the parent panel then you can call Panel2_Touch(...).

Another option which will be simpler is to use Reflection library to add a touch listener (instead of the touch event). With this listener you can choose whether to consume the event or not.
 
Upvote 0

pauleffect

Member
Licensed User
Longtime User
that's exactly what i am after.

Another option which will be simpler is to use Reflection library to add a touch listener (instead of the touch event). With this listener you can choose whether to consume the event or not.

That's exactly what I am after.I already tried it with a with a panel. But surely i did something wrong.

B4X:
Dim r As Reflector
r.Target = p2
r.SetOnTouchListener("blah")


Sub blah_Touch(ViewTag As Object, Action As Int, X As Float, Y As Float, MotionEvent As Object) As Boolean
  if  x / y something ..... ->code
      return true
  else
      return false
  end if
End Sub

is this... close?
 
Upvote 0

pauleffect

Member
Licensed User
Longtime User
damn. this is exactly what i tried, with little luck. must have done something wrong. it'll keep trying. thank you for your assistance. as always, i am in debt.
 
Upvote 0

pauleffect

Member
Licensed User
Longtime User
B4X:
Sub reftes_Touch(ViewTag As Object, Action As Int, X As Float, Y As Float, MotionEvent As Object) As Boolean

    If(X < p2.Width / 2) Then
    test
    Return True
    Else
    Return False
    End If


End Sub

Damn it... dosen't work.
Clicking in the right half of the circle or near it dosen't trigger the test sub (setting a random color background for the view) but neither does it pass through to the square.
 

Attachments

  • Capture.PNG
    Capture.PNG
    52.1 KB · Views: 250
Upvote 0

pauleffect

Member
Licensed User
Longtime User
Hello.
I got it working using a different approach. And I erased the "testing" part of the app.
Thank you for your concern.
 
Upvote 0
Top