B4J Question [ABMaterial] How to detect whether ModalSheet is Open or not

Anser

Well-Known Member
Licensed User
Longtime User
Hi,

Is there any method to detect whether a model sheet is already open or not on a page?

Here is the scenario:-

I have a page with a button and when the button is clicked it opens a ModalSheet.
Once the model sheet is opened, on the Model sheet itself, I have a back button to close the modal sheet.
To close this modal sheet, the user is supposed to click the back button available on the model sheet and go back to the original screen that he was viewing before opening the Modal Sheet.

Unfortunately, some users are clicking on the browser's back button. Doing so will take the user to the previous page. This is not what I need. If the user clicks on the browser's back button, the app should be able to detect whether the model sheet is already open or not, if the modal sheet is already open then it should close the already open modal sheet and then remain on the same page.

Any hints will be appreciated.
 

Anser

Well-Known Member
Licensed User
Longtime User
Have you tried Page.IsModalsheetOpen("modalsheetname")?
Yes. This was the one I was looking for. Thank you. May I ask you one more question.
I need to detect this when the user clicks on the Back button of the BROWSER, so which is the right event in the page to place this check?
 
Upvote 0

Anser

Well-Known Member
Licensed User
Longtime User
There is only page.DisableBackButton = true (to use in BuildPage only!). There is no event that can be raised.
May I know where exactly to place the code. I placed page.DisableBackButton = true inside BuildPage(). Unfortunately, even after adding this code, the back button is not disabled on the browser
B4X:
public Sub BuildPage()
    ' initialize the theme
    BuildTheme
   
    ' initialize this page using our theme
    page.InitializeWithTheme(Name, "/ws/" & ABMShared.AppName & "/" & Name, False, ABMShared.SessionMaxInactiveIntervalSeconds, theme)
    page.ShowLoader=True
    page.PageHTMLName = "index.html"
    page.PageTitle = "Sales Performance Charts"
    page.PageDescription = "Sales Performance Charts"
    page.PageKeywords = ""
    page.PageSiteMapPriority = ""
    page.PageSiteMapFrequency = ABM.SITEMAP_FREQ_YEARLY
    page.DisableBackButton = True
    page.ShowConnectedIndicator = True
   
    'To be enabled, if we Plan to use Google Charts
    page.AddExtraJavaScriptFile("https://www.google.com/jsapi")
               
    ' adding a navigation bar
    ABMShared.BuildNavigationBar(page, "Sales Chart","../images/mylogo.jpg", "", "", "")
           
    ' create the page grid
    page.AddRows(1,True, "").AddCells12(1,"")

    page.BuildGrid 'IMPORTANT once you loaded the complete grid AND before you start adding components
       
End Sub
 
Upvote 0

Anser

Well-Known Member
Licensed User
Longtime User
Yes, this is the correct place. I use this all the time. Which browser are you using? Note that the button itself is not disabled, it just shouldn't do anything when clicked.
I am using Chrome. On Chrome, the browser's BACK button is not getting disabled.
I checked on Mozilla FireFox and found that the BACK button is disabled. Disabled means even if we click nothing will happen.

So the problem is ONLY on Google Chrome
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…