B4J Question [ABMaterial] Trap Click Events of AddSideBarComponent and AddSideBarItem??

Mashiane

Expert
Licensed User
Longtime User
Hi

I want to trap the click events of components added with

B4X:
page.NavigationBar.AddSideBarComponent("TestComp3", BuildSideBarComponent(page, "tcS3", "../images/brother.jpg", "Brother", "My best friend"), "")
page.NavigationBar.AddSideBarItem("GettingStarted", "Getting started", "mdi-editor-insert-comment", "../GettingStartedPage/abmaterial-getting-started.html")

As I want to execute some code first when that happens?

Can someone please advise?

Thanks...
 

mindful

Active Member
Licensed User
You should check:
B4X:
Public Sub Page_NavigationbarClicked(Action As String, Value As String)

When a click in the navigation bar is made it will fire that sub !
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
For each page, I Log in the Page_ParseEvent:

B4X:
Sub Page_ParseEvent(Params As Map)
  
    Dim eventName As String = Params.Get("eventname")
    Dim eventParams() As String = Regex.Split(",",Params.Get("eventparams"))

    Log(" event name: "&eventName&"  "&Params) ' log these...
B4X:
 event name: btnNewMeeting_clicked  (MyMap) {eventparams=target, eventname=btnnewmeeting_clicked, target=btnnewmeeting}

This shows what event was fired (if any - if registered), its' name and what the parameters are for that event. I often forget what the ID name is...

ie.: Standard button click....
event name: btnNewMeeting_clicked (MyMap) {eventparams=target, eventname=btnnewmeeting_clicked, target=btnnewmeeting}

More obscure...
This is from a ABMdatepicker date changed event. It won't fire UNLESS you change the date. ( I did not know - nor would have found it otherwise).
event name: startdate_changed (MyMap) {datemilliseconds=1485158400000, eventparams=target,datemilliseconds, eventname=startdate_changed, target=datebox-content-startdate}

When date has changed, the event fired does this:

B4X:
Sub startdate_changed(Target As String, datt As String)
  
Dim datbox As ABMModalSheet = page.ModalSheet("datebox")
Dim mtmeet As ABMInput = datbox.Content.Component("meetname")
Dim dt As Long
dt = datt
mtmeet.Text = DateTime.Date(dt)
mtmeet.Refresh

Log("milli: "&datt)
' All that happens is a text field is updated to reflect the NEW date chosen. This new text is displayed and stored in a table.
  
End Sub

Actually, since this is SO Important, I shall ask for a feature in Feedback to turn this ON or OFF, as a constant feature.

Without this one simple line: Log(" event name: "&eventName&" "&Params),
I would have no idea as to what has fired or what params are required at any given mouse click.

Essentially, this is how I learned what happens and how ABM works - under the hood.

Everything else is simple coding....

Thanks
 
Upvote 0

mindful

Active Member
Licensed User
Without this one simple line: Log(" event name: "&eventName&" "&Params),
I would have no idea as to what has fired or what params are required at any given mouse click
You can also use B4X Object Browser (https://www.b4x.com/android/forum/t...r-api-documentation-b4x-object-browser.25682/
It show the events and methods of each object in libraries.

Also all of this is in the documentation site ... but some versions are not the latest versions ... some are not listed, but you can see all the methods and events.
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
You can also use B4X Object Browser (https://www.b4x.com/android/forum/t...r-api-documentation-b4x-object-browser.25682/
It show the events and methods of each object in libraries.

Also all of this is in the documentation site ... but some versions are not the latest versions ... some are not listed, but you can see all the methods and events.

Again, live and learn. I was not aware of this.
Shall try and report back of my personal experiences.

For us newbies, who have some to no knowledge, shortcuts like I have presented may work...
 
Upvote 0
Top