Android Question Problems with Label Click Events

hi all, i have a problem with the click events in labels. I try to explain how i reach my problem.
the project have 2 labels (label1 and label2) and the click events, no matter what the events have inside

I will give the steps to follow

1. pres the label1 and holding down
2. touch the label2 - pres and release
3. release the label1

If the user does this, the label2 click event start and when release the label1, the label1 event click overlaps with the label2

What is the best to do to prevent the overlapping click events?

Thanks.
Regards.
 

Cableguy

Expert
Licensed User
Longtime User
Don't use the click event .. instead use the touch event, which has down, move and up triggers... If im not mistaken
 
Last edited:
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
To use the Touch event anyway you have to cover the Labels with Transparent Panels.
Panels has the Touch events.
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
To use the Touch event anyway you have to cover the Labels with Transparent Panels.
Panels has the Touch events.
Since they are labels... why not put each one inside a panel and trigger only the panel's events?
 
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
Since they are labels... why not put each one inside a panel and trigger only the panel's events?
Not sure, but I think that the Label could consume the Touch and don't let it arrive to the panel.

EDIT: I wrote together with @LucaMs šŸ¤£
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
It wouldn't work, the Labels would consume the events.
Not sure, but I think that the Label could consume the Touch and don't let it arrive to the panel.

EDIT: I wrote together with @LucaMs šŸ¤£
I don't recall the exact format, but it's either if the label click event doesn't exist it gets passed to the panel or you need to return true in the label click event to pass through...
Anyway, a click even, no matter what view, only fires on "touch_up" movement
 
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
As I wrote I am not sure about it.
Worth a test.
But I can't help today, sorry.
 
Upvote 0
I am also saying that the 2 labels are only an example. In my project, I have more than 40 buttons and labels with the click event and I need to prevent overlapping events.
Maybe disabling multi-touch or when the first-click event raised dynamically disabling all other click event until the end of the first-click event...

Idk... I need some ideas.

I can't believe no one has this problem
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
I am also saying that the 2 labels are only an example. In my project, I have more than 40 buttons and labels with the click event and I need to prevent overlapping events.
Maybe disabling multi-touch or when the first-click event raised dynamically disabling all other click event until the end of the first-click event...

Idk... I need some ideas.

I can't believe no one has this problem
In the first post I understood something else entirely, that is that you wanted to allow the click of label2 while keeping label1 pressed.

To do what you wrote in the previous post, it is sufficient that each view has the same event name.
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
In the first post I understood something else entirely, that is that you wanted to allow the click of label2 while keeping label1 pressed.
My case exactly, I thought it was a problem with concurrent events.
To do what you wrote in the previous post, it is sufficient that each view has the same event name.
We have 2 possible situations here..
1 - all views point to the same event;
This is doable if they execute similar code and we use the Sender keyword to identify the view that called the event
2 - each view has its own event; all that we need it to create/set a global flag to I dicate that an event is already being executed.
 
Last edited:
Upvote 0
i tought it is clear
all views have diferent events and code inside, so i cant point to the same event.

imagine a layout with 2 buttons, btn1 and btn2.
btn1_click opens a full screen panel1 with info, has a back button
btn2_click opens a full screen panel2 with other info, has a back button

normal use:
the user pres the btn1 / panel1 open
the user cant touch the btn2 until close the panel1
the user close panel1 so now he can pres btn2 and open panel2

in this case: (i need solution for this)
the user pres the btn1 and holding down / nothing happend
with other finger pres btn2 - pres and release / the panel2 opens
when the panel2 is opened complete the user release the btn1 / the panel1 open over panel2

I don't want to let him do that. this is a simple example with panels

so i need if he touch or pres a btn1 he cant touch any other buttons until release btn1 and btn1_click is complete

other case: (i need solution for this to)
the user touch(pres and release) the btn1 and very very fast touch(pres and release) btn2
the events overlaps to...
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
Set the enabled prop to false on the other btn click event!
And set it back to enabled true in the back btn event
 
Last edited:
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
i tought it is clear
all views have diferent events and code inside, so i cant point to the same event.

imagine a layout with 2 buttons, btn1 and btn2.
btn1_click opens a full screen panel1 with info, has a back button
btn2_click opens a full screen panel2 with other info, has a back button

normal use:
the user pres the btn1 / panel1 open
the user cant touch the btn2 until close the panel1
the user close panel1 so now he can pres btn2 and open panel2

in this case: (i need solution for this)
the user pres the btn1 and holding down / nothing happend
with other finger pres btn2 - pres and release / the panel2 opens
when the panel2 is opened complete the user release the btn1 / the panel1 open over panel2

I don't want to let him do that. this is a simple example with panels

so i need if he touch or pres a btn1 he cant touch any other buttons until release btn1 and btn1_click is complete

other case: (i need solution for this to)
the user touch(pres and release) the btn1 and very very fast touch(pres and release) btn2
the events overlaps to...
Even thought that these conditions are pretty inusual.................
This is my solution to the problem.
Maybe a bit strange, it could be done in a better way probably.
As already wrote it use the technique to cover every Button (or any other View that could be Clicked) with a Panel.
Check the code AND the Designer to understand it.
I am available for explanation in the next days if needed (probably not before monday afternoon).
 

Attachments

  • StrangeClicks.zip
    10 KB · Views: 65
Upvote 0

epiCode

Active Member
Licensed User
in this case: (i need solution for this)
the user pres the btn1 and holding down / nothing happend
with other finger pres btn2 - pres and release / the panel2 opens
when the panel2 is opened complete the user release the btn1 / the panel1 open over panel2

I don't want to let him do that. this is a simple example with panels

so i need if he touch or pres a btn1 he cant touch any other buttons until release btn1 and btn1_click is complete

Try adding the following code using manifest editor: ( this disables multitouch )

In Manifest Editor:
AddApplicationText(
<style name="MyTheme" parent="@android:style/Theme.Holo.Light">
    <item name="android:windowEnableSplitTouch">false</item>
<item name="android:splitMotionEvents">false</item>
</style>
)
 
Upvote 0
Hi all, thx for try for helping me... I solved them, but I didn't find a clean way to do it...

B4X:
AddApplicationText(
<style name="MyTheme" parent="@android:style/Theme.Holo.Light">
<item name="android:windowEnableSplitTouch">false</item>
<item name="android:splitMotionEvents">false</item>
</style>
)
Idk why but this dont work for me.

B4X:
B4X:
Private Sub btn1_Click
    btn1.Enabled = False
    pnl1.Visible = True
'(pnl2.Visible = False)
    btn2.Enabled = True
End Sub

Private Sub btn2_Click
    btn2.Enabled = False
    pnl2.Visible = True
'(pnl1.Visible = False)
    btn1.Enabled = True
End Sub
This is viable if i have a few buttons... but if had 40+ is quite imposible to maintenance that

Even thought that these conditions are pretty inusual.................
you are rigth, but if i put this app in the playstore i need to prevent this kind of issues.

This is my solution to the problem.
Maybe a bit strange, it could be done in a better way probably.
As already wrote it use the technique to cover every Button (or any other View that could be Clicked) with a Panel.
Check the code AND the Designer to understand it.
I am available for explanation in the next days if needed (probably not before monday afternoon).
Thx for the demo, I didn't know that panels could be used like that

With everyone's ideas I solved it in the following way:
Because in this project i dont use the longclick event in any lbl or btn, i put all longclicks event without code, only for catch the event
and in all the click events use this
B4X:
Private Sub Button1_Click
    If clicked = 1 Then Return
    clicked = 1
   
       'code here

    clicked = 0
End Sub

It's a shame there isn't a more practical way to solve it. Or at least I haven't found it yet.

Thx guys
 
Upvote 0
Top