B4A Library [B4X] [XUI] [B4XLib] B4XMenuPlus

Extension for B4XPages menu. Replacing B4XPages.AddMenuItem().

When a menu item is selected, an event ( EventName_Tag() ) is triggered.

New features are added:
  • Add text item, checkbox, toogle or submenu on 3dot menu.
  • Add separator on 3dot menu. (two consecutive separators are not allowed and automatic suppressed ) (separator are not clickable)
  • Icons/Bitmaps can be displayed on the bar. Icons are created by FONTAWESOME and MATERIALICONS. Icon/bitmaps can also be toggle elements.
  • All items can be set enabled/disabled (gray out)
  • All items can be set visible/hidden.
  • All 3dot items can have also a icon.
  • Checkbox item. When selected, the status changes and the event is called with EventName_Tag( Checked ).
  • Toggle item. 1 to x rotating states possible. All elements of a toggle have the same Tag, but can have different icons. When selected, the state rotates to the next position and the event is called with EventName_Tag( State ). The state is 0 based.
  • Submenu. Multi level submenus can be created. These can also contain checkbox and/or toggle elements.
    For all instances using submenu, add this lines in Main:
    B4X:
    Sub Activity_WindowFocusChanged (Focused As Boolean)
        If B4XPages.[page].[B4XMenuPlus].IsInitialized Then B4XPages.[page].[B4XMenuPlus].WindowFocusChanged( Focused )
    End Sub
  • All interaction based on the item Tag.
Code Example:
B4X:
Private mp As B4XMenuPlus

mp.Initialize( Me, Root, "MenuClick" )
mp.AddItem( "Test", "Test Menu Item" )
mp.ShowMenu

Private Sub B4XPage_MenuClick( Tag As String )
   mp.MenuClick( Tag )

End Sub

Private Sub MenuClick_Test()
    ...
End Sub

Remark:
The Tag and Title should be unique, to avoid collisions between multiple menus on the same page.

A method returns True or a value.
If False or -1, there is an error. This can be determined using Error() :

0 - ERROR_NO_ERROR
-1 - ERROR_TITLE_NOT_FOUND
-2 - ERROR_TAG_NOT_FOUND
-3 - ERROR_ITEM_NOT_CHECK
-4 - ERROR_ITEM_NOT_TOGGLE
-5 - ERROR_PARENTTAG_NOT_FOUND
-6 - ERROR_PARENTTAG_NOT_SUBMENU
-7 - ERROR_WRONG_MENU_TYPE
-8 - ERROR_ITEM_WRONG_TYPE
-9 - ERROR_STATE_OUT_OF_RANGE
-10 - ERROR_ITEM_IS_DISABLED
-11 - ERROR_MENU_NOT_ACTIVE
-12 - ERROR_CALLBACK_NOT_FOUND
-13 - ERROR_ITEM_WITHOUT_ICON

In debug mode all errors are output via log.

Format: B4XMenuPlus [ EventName – Tag/Title ] ErrorText

Item.gif
____
Item_ToggleCheck.gif
____
Item_Sub.gif



Icon.gif
____
bmp.gif


DepenseOn: XUI, BitmapCreator

Fields:

ERROR_NO_ERROR As Int
ERROR_TITLE_NOT_FOUND As Int
ERROR_TAG_NOT_FOUND As Int
ERROR_ITEM_NOT_CHECK As Int
ERROR_ITEM_NOT_TOGGLE As Int
ERROR_PARENTTAG_NOT_FOUND As Int
ERROR_PARENTTAG_NOT_SUBMENU As Int
ERROR_WRONG_MENU_TYPE As Int
ERROR_ITEM_WRONG_TYPE As Int
ERROR_STATE_OUT_OF_RANGE As Int
ERROR_ITEM_IS_DISABLED As Int
ERROR_MENU_NOT_ACTIVE As Int
ERROR_CALLBACK_NOT_FOUND As Int
ERROR_ITEM_WITHOUT_ICON As Int
isActive As Boolean

Properties:

Error As Int

Methods:

Initialize(Callback As Object, Root As B4XView, EventName As String)​
AddBarBmp(Tag As String, Title As String, bmp As B4XBitmap)​
AddBarIcon(Tag As String, Title As String, isAwesome As Boolean, mChar As String, color As Int) As Boolean
AddBarToggleBmp(Tag As String, Title As String, bmp As B4XBitmap) As Boolean
AddBarToggleIcon(Tag As String, Title As String, isAwesome As Boolean, mChar As String, color As Int) As Boolean
AddItem(Tag As String, Title As String)​
AddItemIcon(Tag As String, Title As String, isAwesome As Boolean, mChar As String, color As Int)​
AddCheckbox(Tag As String, Title As String, checked As Boolean)​
AddToggle(Tag As String, Title As String) As Boolean
AddToggleIcon(Tag As String, Title As String, isAwesome As Boolean, mChar As String, color As Int) As Boolean
AddSeparator
AddSubMenu(Tag As String, Title As String) As Boolean
AddSubSubMenu(parentTag As String, Tag As String, Title As String) As Boolean
AddSubItem(parentTag As String, Tag As String, Title As String) As Boolean
AddSubItemIcon(parentTag As String, Tag As String, Title As String, isAwesome As Boolean, mChar As String, color As Int) As Boolean
AddSubCheckbox(parentTag As String, Tag As String, Title As String, checked As Boolean) As Boolean
AddSubToggle(parentTag As String, Tag As String, Title As String) As Boolean
AddSubToggleIcon(parentTag As String, Tag As String, Title As String, isAwesome As Boolean, mChar As String, color As Int) As Boolean
AddSubSeparator(parentTag As String) As Boolean
GetEnabled(Tag As String) As Boolean
SetEnabled(Tag As String, enabled As Boolean) As Boolean
GetVisible(Tag As String) As Boolean
SetVisible(Tag As String, visible As Boolean) As Boolean
GetCheck(Tag As String) As Boolean
SetCheck(Tag As String, checked As Boolean) As Boolean
GetToggleState(Tag As String) As Int
SetToggleState(Tag As String, state As Int) As Boolean
SetIconColor(Tag As String, color As Int) As Boolean
SetToggleIconColor(Tag As String, state As Int, color As Int) As Boolean
ShowMenu
MenuClick(Title As String) As Boolean
WindowFocusChanged(Focused As Boolean)​
 

Attachments

  • B4xMenuPlus - Example.zip
    49.4 KB · Views: 53
  • B4XMenuPlus.b4xlib
    9.2 KB · Views: 53
  • B4XMenuPlus.xml
    26.6 KB · Views: 47
Last edited:

aeric

Expert
Licensed User
Longtime User
This is a beneficial extension.

When attempting to use the test project, the following error message appeared:


The provides lib files are in the additional libs folder:
View attachment 157408


Where can I obtain the JAR file?
Note that the XML files shouldn't be kept in the libraries folder as the IDE will show an error message about a missing jar file.

Note: The correct way is to post your issue in a new thread (as per your signature, you should never...).
 
Top