B4J Question [ABMaterial] set modal sheet size

Harris

Expert
Licensed User
Longtime User
B4X:
Sub BuildInputSheet() As ABMModalSheet
    Dim inp As ABMModalSheet
    inp.Initialize(page, "inp",   True,   False,  "sheet1")
    inp.IsDismissible = False
   
    ABMShared.setScrnSize( page)  ' this determines if it is a PHONE - sets ScrnSize var

    Log( "build feed sheet size in build input: "&ABMShared.ScrnSize)
   
    If ABMShared.ScrnSize = 0 Then
        inp.Size = ABM.MODALSHEET_SIZE_FULL
    Else
        inp.Size = ABM.MODALSHEET_SIZE_NORMAL
    End If     

      

 Sub setScrnSize(pg As ABMPage)
   
    Dim ret As Int = 2
    Try
    Dim NowWH As String = ABM.GetBrowserWidthHeight( pg) ' returns a string "width;height"
   
   
    If NowWH <> "" And NowWH <> ";" Then ' check if we got something useful back
        Dim split() As String = Regex.Split(";", NowWH) ' split the string
     
       Dim NewH As Int = split(0)
       Log(" width in PX: "&NewH)
       
       
        If NewH < 600 Then ret = 0    ' phone
        If NewH > 600 And NewH <= 992 Then ret = 1  ' tablet landscape
        If NewH > 992 Then ret = 2 ' desktop


    End If
    Catch
        Log(" screen setting failed!")
    End Try   
    Log(" screen width: " &ret)
    ScrnSize = ret
   
End Sub

This doesn't work.

Essentially, I would like ABM.MODALSHEET_SIZE_FULL if phone
or Normal if above phone size. Screwed around to no avail...
 

alwaysbusy

Expert
Licensed User
Longtime User
I suspect you put BuildInputSheet() in the PageBuild()? What I indeed advice.

However, for your purpose you may try to put it in ConnectPage() as it has to 'Build' a different version for each device type.

Everything that is in BuildPage() is 'Static'. It does not know what the browser will be as at that point, it is not yet connected and the html file is written to disk.
So by trying to put it in ConnectPage(), it will have a browser and hence also a width/height.
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
Yes, I tried that yesterday with mixed results.

Tried it again today and it now works (BuildInput in the connect page)!
Thanks again.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…