Hi,
In continuation to my previous "ToggleButtons" Library, (https://www.b4x.com/android/forum/threads/my-toggle-button-library-rotation-issue-solved.91324/)
I am preparing multiple mini libraries for one of my bigger projects.
I though it would be good to share them with you all. If you use them, I would like to have your feedback.
This particular library will create a popup menu on click of any view in the activity. Needless to say you can have as many menus as you want and can call them upon click event.
Usage is simple:
Declare MenuOnAnyView object:
Initialize and add menu items:
Capture the Click Event: Click Event will pass the "MenuName" as parameter.
Other Methods are:
- MenuIsOpen - Returns Boolean
- OpenMenu
- CloseMenu
- DisableMenuItem
- EnableMenuItem
Tip:
If you have multiple MenuOnAnyView objects then you may want to close them all on click of another view. In my example if have created 5 different menu and on click of each I have call a sub to close them all (if open)
Note:
I know that there might be many such libraries already available on the forum like this one or my other library of toggle buttons, but still wanted to create my own ... just for my learning purpose
Finally, I would also like to take this opportunity to thank all the Experts & other members here whom have written and shared so many pieces of code that has helped me so far and would continuously help me through out.
Cheers
In continuation to my previous "ToggleButtons" Library, (https://www.b4x.com/android/forum/threads/my-toggle-button-library-rotation-issue-solved.91324/)
I am preparing multiple mini libraries for one of my bigger projects.
I though it would be good to share them with you all. If you use them, I would like to have your feedback.
This particular library will create a popup menu on click of any view in the activity. Needless to say you can have as many menus as you want and can call them upon click event.
Usage is simple:
Declare MenuOnAnyView object:
B4X:
Dim movImgMenu As MenuOnAnyView
Initialize and add menu items:
B4X:
movImgMenu.Initialize(Activity, Me, imgMenu, Colors.DarkGray, Colors.White, True, False)
movImgMenu.AddMenuItem("Automobiles", "Autos")
movImgMenu.AddMenuItem("Passenger Buses", "Autos")
movImgMenu.AddMenuItem("Trucks", "Autos")
Capture the Click Event: Click Event will pass the "MenuName" as parameter.
B4X:
Sub Autos_Click(MenuName As String)
Select MenuName
Case "Automobiles"
ToastMessageShow("Autos: Cars", False)
Case "Passenger Buses"
ToastMessageShow("Autos: Buses", False)
Case "Trucks"
ToastMessageShow("Autos: Trucks", False)
End Select
End Sub
Other Methods are:
- MenuIsOpen - Returns Boolean
- OpenMenu
- CloseMenu
- DisableMenuItem
- EnableMenuItem
Tip:
If you have multiple MenuOnAnyView objects then you may want to close them all on click of another view. In my example if have created 5 different menu and on click of each I have call a sub to close them all (if open)
B4X:
Sub CloseAllMenus
If movBtnMenu.MenuIsOpen == True Then movBtnMenu.CloseMenu
If movImgMenu.MenuIsOpen = True Then movImgMenu.CloseMenu
If movPmlAvatar.MenuIsOpen = True Then movPmlAvatar.CloseMenu
If movLblMenu.MenuIsOpen = True Then movLblMenu.CloseMenu
If movChkMenu.MenuIsOpen = True Then movChkMenu.CloseMenu
End Sub
Note:
I know that there might be many such libraries already available on the forum like this one or my other library of toggle buttons, but still wanted to create my own ... just for my learning purpose
Finally, I would also like to take this opportunity to thank all the Experts & other members here whom have written and shared so many pieces of code that has helped me so far and would continuously help me through out.
Cheers
Attachments
-
MenuOnAnyView_Example.zip120.2 KB · Views: 458
-
MenuOnAnyView_Lib_1.1.zip5.8 KB · Views: 398
-
Button.png70.4 KB · Views: 1,354
-
chkBox.png69.3 KB · Views: 1,303
-
Image.png71.4 KB · Views: 1,146
-
Label.png66.1 KB · Views: 1,079
-
Panel.png72.1 KB · Views: 1,091
-
MenuOnAnyView_Example_1.2.zip120.3 KB · Views: 458
-
MenuOnAnyView_Lib_1.2.zip7.6 KB · Views: 464
-
MenuOnView_Lib_SurceCode.zip92.5 KB · Views: 492
Last edited: