Android Question OverlayWindow Lib Click Event not working

mr.gedo

Member
Hello Everyone

I try click event for OverlayWindow but nothing happens
when try OverlayButton click event work fine but OverlayButton does not have a touch event so i can't move it
this is the code

B4X:
Sub Process_Globals
    Dim OW As OverlayWindow
End Sub

Sub Service_Create
    CreateInterface
End Sub

Sub CreateInterface

    OW.Initialize(10dip, 10dip, 55dip , 55dip, "Pnl")
    Dim Pnl As Button = OW.Panel
    Pnl.SetBackgroundImage(LoadBitmap(File.DirAssets, "home.png"))
    OW.Open

End Sub


Sub Pnl_Touch(Action As Int, X As Float, Y As Float, ScreenX As Float, ScreenY As Float)
    'Log(Action & " " & X & "," & Y & " " & ScreenX & "," & ScreenY)
    If Action = 0 Then 'DOWN
        InitialPosX = ScreenX - OW.X
        InitialPosY = ScreenY - OW.Y
       
    Else If Action = 2 Then 'MOVE
        'Moves the window
        'OW.SetPosition(ScreenX - InitialPosX, ScreenY - InitialPosY)
        OW.SetPosition(ScreenX - InitialPosX, ScreenY - InitialPosY)

    End If
End Sub


Sub Pnl_Click
ToastMessageShow("Home",True)
End Sub

what's the problem exactly ?
 

Marvel

Member
Licensed User
Hello Everyone

I try click event for OverlayWindow but nothing happens
when try OverlayButton click event work fine but OverlayButton does not have a touch event so i can't move it
this is the code

B4X:
Sub Process_Globals
    Dim OW As OverlayWindow
End Sub

Sub Service_Create
    CreateInterface
End Sub

Sub CreateInterface

    OW.Initialize(10dip, 10dip, 55dip , 55dip, "Pnl")
    Dim Pnl As Button = OW.Panel
    Pnl.SetBackgroundImage(LoadBitmap(File.DirAssets, "home.png"))
    OW.Open

End Sub


Sub Pnl_Touch(Action As Int, X As Float, Y As Float, ScreenX As Float, ScreenY As Float)
    'Log(Action & " " & X & "," & Y & " " & ScreenX & "," & ScreenY)
    If Action = 0 Then 'DOWN
        InitialPosX = ScreenX - OW.X
        InitialPosY = ScreenY - OW.Y
       
    Else If Action = 2 Then 'MOVE
        'Moves the window
        'OW.SetPosition(ScreenX - InitialPosX, ScreenY - InitialPosY)
        OW.SetPosition(ScreenX - InitialPosX, ScreenY - InitialPosY)

    End If
End Sub


Sub Pnl_Click
ToastMessageShow("Home",True)
End Sub

what's the problem exactly ?
What are you trying to do? Do you want to be able to move the overlay button on the screen?
 

mr.gedo

Member
What are you trying to do? Do you want to be able to move the overlay button on the screen?
yes i need to move OverlayButton or when i click on OverlayWindow do something becuse the click event in OverlayWindow not working
 

Marvel

Member
Licensed User
yes i need to move OverlayButton or when i click on OverlayWindow do something becuse the click event in OverlayWindow not working
Use SetPosition to move panels or buttons under Panel_touch or Button_click events.

B4X:
Sub Pnl_Touch(Action as Int, ...other parameters)
If Action = 2 then '2 captures drag
panel1.setposition(x, y) 'position on screen
end if
End Sub
Check the Overlay logger and OverlayInfo Example
 

mr.gedo

Member
Use SetPosition to move panels or buttons under Panel_touch or Button_click events.

B4X:
Sub Pnl_Touch(Action as Int, ...other parameters)
If Action = 2 then '2 captures drag
panel1.setposition(x, y) 'position on screen
end if
End Sub
Check the Overlay logger and OverlayInfo Example
I don't have problem with overlywindow I can moving it easy but I can't click on it.
also I can't moving the overlybutton because the overlybutton doesn't have a touch event so I can't move it I just need to click on overlywindow I try the (click event) but don't work

See the events here

Thank you for help
 
Top