B4A Library [Class] Floating Windows

georgelbs

Member
Licensed User
Longtime User
Thanks Informatix, the code worked after a little fix (add parameter Btn as View)

Public Sub ForcePin(Enabled As Boolean, Btn As View)
'Pins the window on its parent (cannot move)
wPinned = Enabled
' 'Update the state drawables
UpdateStateDrawables(wPinned, Btn)
If SubExists(wModule, OnPinWinSub) Then CallSub2(wModule, OnPinWinSub, Me)
End Sub
 

rafaelbr20

Member
Licensed User
Longtime User
Hi Informatix !

Great Class !

I´m using a transparent window with a background image and with hidden title .

I would like to enable the "close button" even when the title is hidden, but when i hide the title the "close button" dissapear.

Could you help me ?

Thanks so Much

Doesn´t work
B4X:
    Dim win As ClsFloatingWindow
    win.Initialize(Activity, 0, 0, dadosDimensao(0), dadosDimensao(1), Me)
    win.EnableResizeButton(True)
    win.EnableCloseButton(True,True,"Before_Close")
    win.ChangeResizeIcon(LoadBitmap(File.DirAssets,"resize.png"))
    win.ChangeCloseIcon(LoadBitmap(File.DirAssets,"fechar.png"))
    win.EnableTitleBar(False) 'Hidden Title bar


Works
B4X:
    Dim win As ClsFloatingWindow
    win.Initialize(Activity, 0, 0, dadosDimensao(0), dadosDimensao(1), Me)
    win.EnableResizeButton(True)
    win.EnableCloseButton(True,True,"Before_Close")
    win.ChangeResizeIcon(LoadBitmap(File.DirAssets,"resize.png"))
    win.ChangeCloseIcon(LoadBitmap(File.DirAssets,"fechar.png"))
    win.EnableTitleBar(True) 'Show Title bar
 

Informatix

Expert
Licensed User
Longtime User
1) As the class code is provided, feel free to modify it to fit your needs.
2) The first thing to do is probably to set the visibility of all unneeded buttons to False and the color of wTitleBar to Transparent when the title bar is not enabled. Example:
B4X:
Public Sub EnableTitleBar(Enabled As Boolean)
    If Not(Enabled) Then
        If btnPin.IsInitialized Then btnPin.Visible = False
        If btnMaximize.IsInitialized Then btnMaximize.Visible = False
        wTitleBar.Color = Colors.Transparent
    End If
End Sub
 

rafaelbr20

Member
Licensed User
Longtime User


Perfect Informatix !

I´ll try it ! Thanks so Much !

Rafael
 

IdasI4A

Active Member
Licensed User
Longtime User
This is wonderful.

Can you make a window is modal?.
I mean, when this visible, only she receives all keyboard events and screen.

(Original:
Esto es maravilloso.

¿Se puede hacer que una ventana sea modal?.
Osea, que cuando este visible, sólo ella reciba todos los eventos del teclado y de la pantalla.)

Thanks.
Sorry for my English.
 

Informatix

Expert
Licensed User
Longtime User
This is wonderful.

Can you make a window is modal?.
I mean, when this visible, only she receives all keyboard events and screen.

No it is not possible as modal windows require a very different code behind. The common workaround in this case is to ignore the events of all windows other than the one you want to be modal (with a global boolean shared by all windows).
 

IdasI4A

Active Member
Licensed User
Longtime User
Based on your code, I have simulated a modal window.
Would you can take a look?

(Spanish: Basandome en tu código, he simulado una ventana modal.
¿Le puedes echar un vistazo?)
 

Attachments

  • WindowModal.zip
    8.1 KB · Views: 316

billyrudi

Active Member
Licensed User
Longtime User
Hi good job
There is a way to loop in each the windows views that i have added?
 

deantangNYP

Active Member
Licensed User
Longtime User
Please advise.. Thanks.
From your sample code, if I wish to stop the W(0) from moving, is this the way to do it?
by adding "W(0).Move(-1,-1,False)" ?
B4X:
Sub After_Move(Window As ClsFloatingWindow)
    If Sender = W(0) Then
        W(0).Move(-1,-1,False)
    End If
  
    Log("NewX=" & Window.getLeft)
    Log("NewY=" & Window.getTop)
End Sub
 

Informatix

Expert
Licensed User
Longtime User
The better way is to modify the class to allow to change the state of wPinned. With wPinned = true, the window cannot move.
 

leonardo pino

Member
Licensed User
Longtime User
Hi, in the Example FloatWinDemo2, I want use an image Background,
but not how to do it,

I try:
Win.SetBackground= LoadBitmap(File.DirAssets,"fruit_0.png")
Win.SetBackground= (File.DirAssets,"fruit_0.png")
Win.SetBackground= ("fruit_0.png")

It Don't Work...

Thanks By your help,
 

Informatix

Expert
Licensed User
Longtime User
As the function help says, Background needs a valid drawable, so a bitmap cannot be used here. You have to convert it to a BitmapDrawable.
 

Ondra

Member
Licensed User
Longtime User
Hi !
It is nice work man I am trying to do something simillar, but I need to stick panels each other, if the gap beetween panels would be smaller than for exp. 5dip. But because all objects are inserted dynamically, I cannot find way, how to detect collision of the objects. Have you any idea, please ?
I will be glad for any advice ;-)
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…