Bug? Click event lost When Using SetLayoutAnimated

Matt S.

Member
Licensed User
I have a Label in a Panel. When I move the label in the panel by "SetLayoutAnimated", click events will be lost. In other words neither Label.Click() nor Panel.Touch will be called.
Note:
1) Everything is Ok without "SetLayoutAnimated"
2) The code runs correctly in B4A.

I would be grateful if Erel would look into the situation.
 

Matt S.

Member
Licensed User
I have provided the sample project. It is about 1MB and it is beyond the upload limit. What can I do?
 

Matt S.

Member
Licensed User
Dear Erel
The sample program was attached.
In B4A you may catch the Label every time.
In B4i you may catch the Label only when it is NOT moving. When it is moving neither Label.Click() nor Panel.Touch will be called.
 

Attachments

  • TestMovingLabelClick.zip
    22.7 KB · Views: 24

angel_

Well-Known Member
Licensed User
Longtime User
Thank you for the tip.
But do you have an an idea about how to resolve the problem?
Did you try declaring it as B4XView?

(Check the XUI Views library)

B4X:
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    
    Private pnlMain As Panel
    Private lblCatchMe As B4XView
    Private tmrMove As Timer
    Private blnMoving As Boolean
    Private blnReverse As Boolean
    Private intduration As Int
End Sub

Public Sub Initialize
'    B4XPages.GetManager.LogEvents = True
End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    
    intduration=3000
    
    pnlMain.Initialize("pnlMain")
    Root.AddView(pnlMain,0,0,100%x,100%y)
    
    lblCatchMe = XUIViewsUtils.CreateLabel
    lblCatchMe.Color=Colors.Red
    lblCatchMe.TextColor=Colors.White
    lblCatchMe.Text="Catch me if you can!"
    pnlMain.AddView(lblCatchMe,30%x,0,40%x,20%y)
    
    blnMoving=True
    blnReverse=False
    
    tmrMove.Initialize("tmrMove",intduration)
    tmrMove.Enabled=True
End Sub

Private Sub tmrMove_Tick()
    If blnMoving Then
        If blnReverse Then
            lblCatchMe.SetLayoutAnimated(intduration,30%x,0,40%x,20%y)
        Else
            lblCatchMe.SetLayoutAnimated(intduration,30%x,80%y,40%x,20%y)
        End If
        blnReverse=Not(blnReverse)
    End If
    blnMoving=Not(blnMoving)
End Sub
 

Matt S.

Member
Licensed User
I tried it. That was a good idea. B4XView doesn't catch the event and the event is passed to the Panel.

Thank you very much.
 

Matt S.

Member
Licensed User
Hello again!
There is still a problem.
I can't realize where is the animating Label at the moment and whether the user touched the Label or everywhere on the Panel.
Unfortunately when you use "SetLayoutAnimated", the "Left" and "Top" properties return the final destination point.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…