B4J Question [SOLVED] ABMaterial strange problem in modalsheet button: clik event, the first click is ignored

Gnappo jr

Active Member
Licensed User
Longtime User
In an ABMModalSheet I inserted some ABMInput and 2 ABMbutton fields
I use the ABMbutton to vary the quantities.
The first click on ABMButton I have no event, while on the second click the _click event is shown.
If instead I first click on an empty cell or any ABMInput field and then on the ABMButton, the _click event occurs correctly on the first click.
It almost seems that the first click is used to give the focu to the ABMModal sheet.
Has anyone encountered this problem?
 
Last edited:

Harris

Expert
Licensed User
Longtime User
Is this on your desktop or a mobile device?
 
Upvote 0

Gnappo jr

Active Member
Licensed User
Longtime User
I never experienced that (and I do use modalsheets as message boxes, so a click on the close button would be the first even). Some code you could share that demonstrates this would help.

I need to change a quantity by acting on two plus and minus keys, so to learn I did the following:
I take lesson 3 of the tutorial as a starting point: [ABMaterial For Dummies]
I modified the code of the UserPage.bas module by inserting the following code in the Sub BuildInputSheet:
B4X:
Sub BuildInputSheet() As ABMModalSheet
    Dim inp As ABMModalSheet
    inp.Initialize(page, "inp",  False,  False,"")
    inp.IsDismissible = False
    
    inp.Content.AddRowsM(5, True,0,0, "").AddCells12(1, "")
    inp.Content.BuildGrid
    
    ' add paragraph
    inp.Content.CellR(0,1).AddComponent(ABMShared.BuildParagraphBQWithZDepth(page,"par1x1","Enter the information for this user.") )
    
    Dim combo1 As ABMCombo
    combo1.Initialize(page, "combo1", "User Type", 650 , "lightblue")
    
    ' add items
    combo1.AddItem("combo1S1", "Admin", BuildSimpleItem("S1", "mdi-action-account-circle", "{NBSP}{NBSP}Admin"))
    combo1.AddItem("combo1S2", "User", BuildSimpleItem("S2", "mdi-action-account-circle", "{NBSP}{NBSP}User"))
    combo1.AddItem("combo1S0", "Guest", BuildSimpleItem("S3", "mdi-action-dashboard", "{NBSP}{NBSP}Guest"))
    
    inp.Content.CellR(1,1).AddComponent(combo1)
    
    Dim inpName As ABMInput
    inpName.Initialize(page, "inpName", ABM.INPUT_TEXT, "Name", False, "lightblue")
    inp.Content.CellR(1,1).AddComponent(inpName)
        
    '>Modificata --inserted--------------------------------------------------------------
    Dim qta As ABMInput
    qta.Initialize(page, "qta", ABM.INPUT_TEXT, "Quantità", False, "lightblue")
    qta.IconName = "mdi-action-add-shopping-cart"
    inp.Content.CellR(1,1).AddComponent(qta)
        
    Dim PBtn As ABMButton
    'p.Size=5
    PBtn.InitializeFloating   (page,   "PBtn", "mdi-content-add","positive")
    inp.Content.CellR( 1,1).AddComponent(PBtn)
    '---------------------------------------------------------------------------    
    
    inp.Footer.AddRowsM(1,True,0,0, "").AddCells12(1,"")
    inp.Footer.BuildGrid 'IMPORTANT once you loaded the complete grid AND before you start adding components
        
    ' create the buttons for the footer, create in opposite order as aligned right in a footer
    Dim CancelBtn As ABMButton
    CancelBtn.InitializeFlat(page, "CancelBtn", "", "", "CANCEL", "transparent")
    inp.Footer.Cell(1,1).AddComponent(CancelBtn)
    
    Dim SaveBtn As ABMButton
    SaveBtn.InitializeFlat(page, "SaveBtn", "", "", "SAVE", "transparent")
    inp.Footer.Cell(1,1).AddComponent(SaveBtn)
        
    Return inp
End Sub
and I added this Sub
B4X:
Sub PBtn_Clicked(Target As String) 'qta
    qx=qx+1
    Dim rcell As Int=4
    'chiama la tua nuova versione di questo foglio come vuoi - purché faccia riferimento al nome della build: = page.ModalSheet ("inp")
    Dim ABMGentiInsp_TypeModal As ABMModalSheet = page.ModalSheet("inp")
    
    ABMGentiInsp_TypeModal.Content.Cell(rcell,1).RemoveAllComponents   
    
    Dim qta As ABMInput
    qta.Initialize(page,   "qx", ABM.INPUT_TEXT, "Quantità "&qx, False, "lightblue")
    qta.IconName = "mdi-action-add-shopping-cart" '
    ABMGentiInsp_TypeModal.Content.Cell(rcell,1).AddComponent(qta)
    ABMGentiInsp_TypeModal.Content.Cell(rcell,1).Refresh
        
End Sub
this is the modalsheet shown
Important: press the '+' key without scrolling.

I have attached the complete program that I used to study, I made some small changes to [ABM for dummies lesson 3] to adapt it to my Microsoft sqlserver database.
A heartfelt thanks to all.


Annotazione 2020-05-03 202729.PNG.jpg
 

Attachments

  • Template.zip
    43.9 KB · Views: 180
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
I'll have a look at it tomorrow and report back. I think it may have something to do with the scrollbar at the right (maybe somehow it got the focus?). It is rather weird that it has a scrollbar at all. The size of the the ModalSheet doesn't imply to need one. But I'll check it out!
 
Last edited:
Upvote 0

Harris

Expert
Licensed User
Longtime User
Easily this! it has to do with the right scroll bar I checked. If it doesn't appear, everything works.
Thanks for all.
So it has been solved?

If so, please update the subject line with [Solved] - your subject...

"it has to do with the right scroll bar I checked" - where did you manage to do this?

Thanks
 
Upvote 0

Gnappo jr

Active Member
Licensed User
Longtime User
So it has been solved?

If so, please update the subject line with [Solved] - your subject...

"it has to do with the right scroll bar I checked" - where did you manage to do this?

Thanks
I have reduced the cells of the modalsheet so that the scroll bar does not appear. The more than solved problem has been 'circumvented'.
 
Upvote 0
Top