B4J Library [ABMaterial] Creating ABMModalSheets at runtime: Part 3

Mashiane

Expert
Licensed User
Ola

This part of this class provides one with a helper class to get all events code linked to each of the components added to the modal sheet. This code is nicely written to the B4X log, so that one can copy and paste it to their pages code. This is meant to simplyfy the coding process.

When one initialized an ABM component, an event is created that gets linked to the ID of the component.
I have created a quick reference to all ABM events here for all components.

In out example in part 2 we added some components to the modal sheet, if we wanted to trap the component events, we would have to type each of the following subs for all the components there for the events that we need.

To recap, we added the following code to create our runtime modal sheet.

B4X:
Sub btnMdl1_Clicked(Target As String)
    mymdl1.Initialize(page,"simplelogin1","Additional Modal").SetModalSheet(theme,ABM.MODALSHEET_SIZE_FULL,ABM.MODALSHEET_TYPE_NORMAL,False,"id","users")
    mymdl1.IsTextSelectable = False
    mymdl1.IsDismissible = False
    mymdl1.ForceLeft = True
    mymdl1.CenterHeading = True
    mymdl1.WhiteHeading = True
    mymdl1.UseControlPrefixes = False
    'mymdl1.CenterInPage = False
    mymdl1.AddImage("img","Image","../images/sponge.png",1,2,0,0,0,12,3,3).SetImageFixedSize("img",100,100).SetImage("img", True, False,False,1,False,ABM.ZDEPTH_2).SetPadding("img",0,0,10,0)
    mymdl1.AddFileInput("upl","Select Profile Picture",1,3,0,0,0,12,3,3).SetFileInput("upl",ABM.VISIBILITY_HIDE_ALL,True)
    mymdl1.AddSignaturePad("sig",1,4,0,0,0,3,3,3,True).SetSignaturePad("sig",100,200,ABM.COLOR_WHITE,ABM.INTENSITY_NORMAL,ABM.COLOR_BLACK,ABM.INTENSITY_NORMAL,ABM.ZDEPTH_1)
    mymdl1.AddPatternLock("ptn",3,1,5,0,0,0,3,3,3,True)
    mymdl1.AddPassword("password","Password","",2,1,0,0,0,12,6,6,True).AddEmail("email","Email","",2,2,0,0,0,12,6,6,True)
    mymdl1.AddTelephone("telephone","Telephone","",3,1,0,0,0,12,6,6,True).AddWebsite("website","Website","",3,2,0,0,0,12,6,6,True)
    mymdl1.AddCheckBox("chk","ABMCheckBox","1",4,1,0,0,0,12,6,6).SetPadding("chk",0,0,10,0)
    mymdl1.AddSwitch("swt","ABMSwitch","0",4,2,0,0,0,12,6,6).SetPadding("swt",0,0,10,0)
    mymdl1.AddComboBox("cbo","ABMComboBox","",5,1,0,0,0,12,6,6,True).AddRadioGroup("rad","ABMRadioGroup","",5,2,0,0,0,12,6,6)
    mymdl1.AddRadioGroupItem("rad","Male",True,True).AddRadioGroupItem("rad","Female", True,True)
   
    'set items for the combobox
    Dim lst As List
    lst.Initialize
    lst.add(CreateMap("id":-1,"title":""))
    lst.add(CreateMap("id":1,"title":"A"))
    lst.add(CreateMap("id":2,"title":"B"))
    lst.add(CreateMap("id":3,"title":"C"))
    lst.add(CreateMap("id":4,"title":"D"))
    lst.add(CreateMap("id":5,"title":"E"))
    mymdl1.SetCombo("cbo","id","title",lst,"-1")
   
    mymdl1.AddRange("range1",6,1,0,0,0,12,6,6).SetPadding("range1",0,0,10,10)
    mymdl1.AddSlider("slider1",6,2,0,0,0,12,6,6).SetPadding("slider1",0,0,20,20)
   
    Dim mfrange As MashForm
    mfrange.Initialize(page,"range","ABMRange")
    mfrange.CenterInPage = False
    mfrange.AddRange("range",2,1,0,0,0,12,12,12).SetPadding("range",0,0,10,10)  
    Dim crange As ABMContainer = mfrange.BuildContainer("Loan Amount")
    mymdl1.AddContainer(mfrange.id,crange,7,1,0,0,0,12,6,6).SetPadding(mfrange.id,0,0,10,10)

    Dim mfslider As MashForm
    mfslider.Initialize(page,"slider","ABMSlider")
    mfslider.CenterInPage = False
    mfslider.AddSlider("slider",2,1,0,0,0,12,12,12).SetPadding("slider",0,0,10,10)
    Dim cslider As ABMContainer = mfslider.BuildContainer("Payment Period")
    mymdl1.AddContainer(mfslider.id,cslider,7,2,0,0,0,12,6,6).SetPadding(mfslider.id,0,0,20,20)
   
    mymdl1.AddRange1("loanamount","Loan Amount",5,50,0,100,5,True,8,1,0,0,0,12,6,6)
    mymdl1.AddSlider1("paymentperiod","Payment Period",6,0,100,2,True,8,2,0,0,0,12,6,6)
   
   
    'mymdl1.AddEditor("editor","Editor","Mashy",6,1,1,1,1,11,11,11,False)
    'mymdl1.AddButton("raised","Raised Button",7,1,0,0,0,4,4,4)
    'mymdl1.AddFlatButton("flat","Flat Button",7,2,0,0,0,4,4,4).SetButton("flat","","","",ABM.BUTTONSIZE_LARGE,True)
    'mymdl1.AddFloatingButton("floating","mdi-editor-mode-edit",7,3,0,0,0,4,4,4)
    mymdl1.show
    LogError(mymdl1.GetEvents)
   
End Sub
Because each control is inside a modal sheet, the component names are prefixed by the name of the modal sheet e.g. simpleform1

B4X:
'simplelogin1img ABMImage Events
Sub simplelogin1img_Clicked(Target As String)
End Sub
'simplelogin1upl ABMFileInput Events
Sub simplelogin1upl_Changed(value As String)
End Sub
'simplelogin1ptn ABMPatternLock Events
Sub simplelogin1ptn_Changed(target as String, value as String)
End Sub
'simplelogin1password ABMInput Events
Sub simplelogin1password_AutoCompleteClicked(uniqueId as String)
End Sub
Sub simplelogin1password_Changed(value As String)
End Sub
Sub simplelogin1password_EnterPressed(value As String)
End Sub
Sub simplelogin1password_GotFocus()
End Sub
Sub simplelogin1password_LostFocus()
End Sub
Sub simplelogin1password_TabPressed(target As String, value As String)
End Sub
'simplelogin1email ABMInput Events
Sub simplelogin1email_AutoCompleteClicked(uniqueId as String)
End Sub
Sub simplelogin1email_Changed(value As String)
End Sub
Sub simplelogin1email_EnterPressed(value As String)
End Sub
Sub simplelogin1email_GotFocus()
End Sub
Sub simplelogin1email_LostFocus()
End Sub
Sub simplelogin1email_TabPressed(target As String, value As String)
End Sub
'simplelogin1telephone ABMInput Events
Sub simplelogin1telephone_AutoCompleteClicked(uniqueId as String)
End Sub
Sub simplelogin1telephone_Changed(value As String)
End Sub
Sub simplelogin1telephone_EnterPressed(value As String)
End Sub
Sub simplelogin1telephone_GotFocus()
End Sub
Sub simplelogin1telephone_LostFocus()
End Sub
Sub simplelogin1telephone_TabPressed(target As String, value As String)
End Sub
'simplelogin1website ABMInput Events
Sub simplelogin1website_AutoCompleteClicked(uniqueId as String)
End Sub
Sub simplelogin1website_Changed(value As String)
End Sub
Sub simplelogin1website_EnterPressed(value As String)
End Sub
Sub simplelogin1website_GotFocus()
End Sub
Sub simplelogin1website_LostFocus()
End Sub
Sub simplelogin1website_TabPressed(target As String, value As String)
End Sub
'simplelogin1swt ABMSwitch Events
Sub simplelogin1swt_Clicked(Target As String)
End Sub
'simplelogin1cbo ABMCombo Events
Sub simplelogin1cbo_Changed(value As String)
End Sub
Sub simplelogin1cbo_Clicked(itemId as String)
End Sub
Sub simplelogin1cbo_GotFocus()
End Sub
Sub simplelogin1cbo_LostFocus()
End Sub
'simplelogin1rad ABMRadioGroup Events
Sub simplelogin1rad_Clicked(Target As String)
End Sub
'simplelogin1range1 ABMRange Events
Sub simplelogin1range1_Changed(start as String, stop as String)
End Sub
'simplelogin1slider1 ABMSlider Events
Sub simplelogin1slider1_Changed(value as String)
End Sub
'simplelogin1range ABMContainer Events
Sub simplelogin1range_AnimationFinished(Target as String, lastAnimation As String)
End Sub
Sub simplelogin1range_NextContent(TriggerComponent As String)
End Sub
'simplelogin1slider ABMContainer Events
Sub simplelogin1slider_AnimationFinished(Target as String, lastAnimation As String)
End Sub
Sub simplelogin1slider_NextContent(TriggerComponent As String)
End Sub
Fortunately with the MashForm, executing the GetEvents method call will automatically generate this code for you to paste to your page for all the components added via MashForm.

You can then add your app code to knit your application together.
 
Top