Extension for B4XPages menu. Replacing B4XPages.AddMenuItem().
When a menu item is selected, an event ( EventName_Tag() ) is triggered.
New features are added:
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
____
____
____
DepenseOn: XUI, BitmapCreator
History:
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.
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
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)
History:
- 1.00
First release - 1.01
3Dot: Finetuning of icon size and position.Bar: Toggle icon color change missing.
Attachments
Last edited: