hello everyone !!
i would like to create some borderless window, and at the top I would like to add a Pane so I can click and drag the window, is this possible?
Not sure if this matters to you, but if your app is meant to run mainly on Linux: All windows can be moved by simply pressing alt and dragging somewhere in the window. (Pretty great feature, by the way.)
And if you want a borderless panel to follow a header panel..
B4X:
Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private Pane1 As Pane
Private Pane2 As Pane
Private pointInPanelX As Float
Private pointInPanelY As Float
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")
End Sub
Private Sub Pane1_MouseDragged (EventData As MouseEvent)
Pane1.Left = Pane1.Left + (EventData.X - pointInPanelX)
Pane1.Top = Pane1.Top + (EventData.Y - pointInPanelY)
Pane2.Left = Pane1.Left
Pane2.Top = Pane1.Top + Pane1.height
End Sub
Private Sub Pane1_MousePressed (EventData As MouseEvent)
pointInPanelX = EventData.X
pointInPanelY = EventData.Y
End Sub
And if you want a borderless panel to follow a header panel..
B4X:
Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private Pane1 As Pane
Private Pane2 As Pane
Private pointInPanelX As Float
Private pointInPanelY As Float
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")
End Sub
Private Sub Pane1_MouseDragged (EventData As MouseEvent)
Pane1.Left = Pane1.Left + (EventData.X - pointInPanelX)
Pane1.Top = Pane1.Top + (EventData.Y - pointInPanelY)
Pane2.Left = Pane1.Left
Pane2.Top = Pane1.Top + Pane1.height
End Sub
Private Sub Pane1_MousePressed (EventData As MouseEvent)
pointInPanelX = EventData.X
pointInPanelY = EventData.Y
End Sub
Sub Class_Globals
Private Root As B4XView 'ignore
Private xui As XUI 'ignore
Private Button1 As Button
Private SystemMenu As Pane
Private pointInPanelX As Float
Private pointInPanelY As Float
Dim GameForm As Form
End Sub
'You can add more parameters here.
Public Sub Initialize As Object
Return Me
End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
'load the layout to Root
Root.LoadLayout("game")
GameForm = B4XPages.GetNativeParent(Me)
GameForm.SetFormStyle("UNDECORATED")
End Sub
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
Sub Button1_Click
B4XPages.ShowPageAndRemovePreviousPages("mainpage")
End Sub
Private Sub B4XPage_CloseRequest As ResumableSub
Log("Game CloseRequest")
ExitApplication
Return True
End Sub
Private Sub SystemMenu_MouseDragged (EventData As MouseEvent)
GameForm.WindowLeft = GameForm.WindowLeft + (EventData.X - pointInPanelX)
GameForm.WindowTop = GameForm.WindowTop + (EventData.Y - pointInPanelY)
Log(GameForm.WindowLeft)
Log(GameForm.WindowTop)
End Sub
Private Sub SystemMenu_MousePressed (EventData As MouseEvent)
pointInPanelX = EventData.X
pointInPanelY = EventData.Y
End Sub
Solved !! Thanks by you help . found this topic : TOPIC
B4X:
Sub SystemMenu_MousePressed (EventData As MouseEvent)
downX = EventData.X
downY = EventData.Y
End Sub
Sub SystemMenu_MouseDragged (EventData As MouseEvent)
Dim jo As JavaObject = EventData
B4XPages.GetNativeParent(Me).WindowLeft = jo.RunMethod("getScreenX", Null) - downX
B4XPages.GetNativeParent(Me).WindowTop = jo.RunMethod("getScreenY", Null) - downY
End Sub