setOnBalloonOutsideTouchListener is not getting invoked when clicking outside the popup nor the setOnBalloonOverlayClickListener
Closed this issue · 8 comments
- Library Version 1.6.7
- Affected Device(s) Was testing on my own device Mi POCO X3
I am showing tool tip on a button with overlay in my project and its getting visible fine. Now i want when user clicks on button bounds the click should be passed to the button and its action should be performed. I tried using passClickToAnchor(true) but it didn't worked. Then tried setOnBalloonOutsideTouchListener and setOnBalloonOverlayClickListener but it also was not invoked when i clicked on the overlay or clicked anywhere outside the tooltip balloon. Am i missing something or is it a bug?
I expect that if i have set passClickToAnchor(true) while creating balloon using createBalloon{} kotlin dsl the click should be passed to the anchor if the click is in the bounds which is not happening currently.
Here's how i created it
`val textForm = TextForm.Builder(fragmentContext)
.setText(fragmentContext.resources.getString(R.string.click_to_view_directions))
.setTextColorResource(R.color.text_color_primary)
.setTextSize(14f)
.setTextTypeface(ResourcesCompat.getFont(fragmentContext, R.font.poppins_regular))
.setIncludeFontPadding(false)
.build()
val balloon = createBalloon(fragmentContext) {
setWidth(BalloonSizeSpec.WRAP)
setHeight(BalloonSizeSpec.WRAP)
setTextForm(textForm)
setArrowPositionRules(ArrowPositionRules.ALIGN_ANCHOR)
setArrowSize(10)
setArrowPosition(0.5f)
setPaddingHorizontal(16)
setPaddingVertical(12)
setCornerRadius(16f)
setElevation(0)
setShouldPassTouchEventToAnchor(true)
setBackgroundColorResource(R.color.background_color_0)
setBalloonAnimation(BalloonAnimation.OVERSHOOT)
setLifecycleOwner(viewLifecycleOwner)
setOverlayColorResource(R.color.black_overlay)
setOverlayShape(BalloonOverlayRoundRect(12f, 12f))
setIsVisibleOverlay(true)
setOverlayPadding(6f)
setBalloonHighlightAnimation(BalloonHighlightAnimation.SHAKE)
build()
}
//its not getting invoked when i click anywhere on overlay nor setShouldPassTouchEventToAnchor works
tooltipBalloon.setOnBalloonOverlayClickListener {
Toast.makeText(context, "touched outside", Toast.LENGTH_SHORT).show()
}`
Hi, would you add the code below on your builder?
.setDismissWhenTouchOutside(false)
It worked, Thanks but i also want that when i click on the anchor view along with passing the click to the anchor the balloon and overlay dismisses as well, can we achieve that as well?
Currently the click is being passed to the anchor if i click with the bounds of the anchor but overlay and tooltip stays.
I don't get what issue you are describing. Do you mean you need to allow clicking the outside but if you click the anchor view, it should dismiss the balloon? Not sure if this works.
.setDismissWhenTouchOutside(false)
.setFocusable(false)
What i want is :-
Case 1 :- when click happens within the bounds of anchor view the click gets passed to the anchor view and balloon also dismisses.
Case 2 :- When click happens outside the bounds of anchor view(anywhere on screen but not on the anchor view) that should dismiss the balloon only.
Case 1: You can just call the balloon.dismiss()
method on your anchor view.
Case 2: You can call the balloon.dismiss()
method inside setOnBalloonOverlayClickListener
.
Btw, there's no way that you can pass a click event through the overlay to your anchor view. It's an entire window the will be displayed on your screen.
So i need to set .setDismissWhenTouchOutside(false)
as well and use the solution you provided for the dismiss cases right?
@CoderGautam07 Yes, you should use it together.