B4A Library [B4X] [XUI] AS PopupMenuAdvanced based on xCustomListView

This is a PopupMenu with a xCustomListView, so you can add simply new rows. And also add build in separator or title without having to worry about it yourself.

Not all functions of the normal PopupMenu are available yet. For now it has only the functions I needed for my project.

I spend a lot of time in creating views, like this and to create a high quality view cost a lot of time. If you want to support me and further views, then you can do it here by Paypal or with a coffee. :)

This view is tested on B4A, B4I and B4J. Screenshot from my project.
ezgif.com-gif-maker.gif
IMG_2001.jpg
IMG_2057.jpg
IMG_2058.jpg

ASPopupMenuAdvanced
Author: Alexander Stolte
Version: 1.01

  • ASPM_SeparatorPropertiesAdvanced
    • Fields:
      • BackgroundColor As Int
      • Height As Float
      • IsInitialized As Boolean
        Tests whether the object has been initialized.
    • Functions:
      • Initialize
        Initializes the fields to their default value.
  • ASPM_TitleLabelPropertiesAdvanced
    • Fields:
      • BackgroundColor As Int
      • Height As Float
      • IsInitialized As Boolean
        Tests whether the object has been initialized.
      • ItemBackgroundColor As Int
      • LeftRightPadding As Float
      • TextAlignment_Horizontal As String
      • TextAlignment_Vertical As String
      • TextColor As Int
      • xFont As B4XFont
    • Functions:
      • Initialize
        Initializes the fields to their default value.
  • ASPopupMenuAdvanced
    • Events:
      • ItemClick (Index As Int, Tag As Object)
      • ItemLongClick (Index As Int, Tag As Object)
      • MenuClosed
    • Fields:
      • AutoHideMs As Int
      • CloseDurationMs As Int
      • OpenDurationMs As Int
    • Functions:
      • AddItem (xPnl As B4XView, Value As Object) As String
        Add a item e.g. a panel with checkboxes
      • AddItemAt (Index As Int, xPnl As B4XView, Value As Object) As String
        Add a item at a special index
      • AddSeparator As String
        Add a separator
      • AddTitle (Text As String, Height As Float) As String
        Add a title
      • Class_Globals As String
      • Clear As String
        Clears the list
      • CloseMenu As String
        Close the menu
      • CreateASPM_SeparatorPropertiesAdvanced (Height As Float, BackgroundColor As Int) As ASPM_SeparatorPropertiesAdvanced
      • CreateASPM_TitleLabelPropertiesAdvanced (TextColor As Int, xFont As B4XFont, TextAlignment_Vertical As String, TextAlignment_Horizontal As String, BackgroundColor As Int, ItemBackgroundColor As Int, LeftRightPadding As Float, Height As Float) As ASPM_TitleLabelPropertiesAdvanced
      • getCustomListView As b4a.example3.customlistview
        gets the xCustomListView
      • getOrientationHorizontal_LEFT As String
      • getOrientationHorizontal_MIDDLE As String
      • getOrientationHorizontal_RIGHT As String
      • getOrientationVertical_BOTTOM As String
      • getOrientationVertical_TOP As String
        Vertical = Top,Bottom
        Horizontal = Left,Middle,Right
      • getSeparatorProperties As ASPM_SeparatorPropertiesAdvanced
        change the separator properties, call it before you add the title
        <code>ASScrollingTags1.TitleLabelProperties.xFont = xui.CreateDefaultBoldFont(20)</code>
      • getTitleLabelProperties As ASPM_TitleLabelPropertiesAdvanced
        change the label properties, call it before you add the title
        <code>ASScrollingTags1.TitleLabelProperties.xFont = xui.CreateDefaultBoldFont(20)</code>
      • Initialize (Parent As B4XView, CallBack As Object, EventName As String) As String
        Initializes the object. You can add parameters to this method if needed.
      • IsInitialized As Boolean
        Tests whether the object has been initialized.
      • OpenMenu (Width As Float, Height As Float)
        Opens the menu
      • OpenMenuOnView (xView As B4XView, Width As Float, Height As Float)
        Opens the menu attached to a view
      • Resize (ParentWidth As Float, ParentHeight As Float) As String
      • setActivityHasActionBar (value As Boolean) As String
      • setCornerRadius (radius As Int) As String
        sets the corner radius from the menu
      • setDividerHeight (height As Int) As String
      • setIsInSpecialContainer (value As Boolean) As String
        set it true if the target is on a listview or as a child on a panel where the left and top values differ from the form
      • setMenuViewGap (Gap As Float) As String
        sets the gap between the menu and the attached view
        only affected if you open the menu with OpenMenuOnView
      • setOrientationVertical (orientation As String) As String
      • ViewScreenPosition (view As B4XView) As Int()
    • Properties:
      • ActivityHasActionBar
      • CornerRadius
        sets the corner radius from the menu
      • CustomListView As b4a.example3.customlistview [read only]
        gets the xCustomListView
      • DividerHeight
      • IsInSpecialContainer
        set it true if the target is on a listview or as a child on a panel where the left and top values differ from the form
      • MenuViewGap
        sets the gap between the menu and the attached view
        only affected if you open the menu with OpenMenuOnView
      • OrientationHorizontal_LEFT As String [read only]
      • OrientationHorizontal_MIDDLE As String [read only]
      • OrientationHorizontal_RIGHT As String [read only]
      • OrientationVertical
      • OrientationVertical_BOTTOM As String [read only]
      • OrientationVertical_TOP As String [read only]
        Vertical = Top,Bottom
        Horizontal = Left,Middle,Right
      • SeparatorProperties As ASPM_SeparatorPropertiesAdvanced [read only]
        change the separator properties, call it before you add the title
        <code>ASScrollingTags1.TitleLabelProperties.xFont = xui.CreateDefaultBoldFont(20)</code>
      • TitleLabelProperties As ASPM_TitleLabelPropertiesAdvanced [read only]
        change the label properties, call it before you add the title
        <code>ASScrollingTags1.TitleLabelProperties.xFont = xui.CreateDefaultBoldFont(20)</code>
Changelog
  • 1.00
    • Release
  • 1.01
    • Add OpenMenuOnView - opens the view attached on a view
    • Add set IsInSpecialContainer - set it true if the target is on a listview or as a child on a panel where the left and top values differ from the form
    • Add set ActivityHasActionBar
    • Add set OrientationVertical
    • Add set MenuViewGap - sets the gap between the menu and the attached view
      • only affected if you open the menu with OpenMenuOnView
  • 1.02
    • Add get isOpen - checks if the menu is open
  • 1.03
    • Add set MenuViewGap - sets the gap between the menu and the attached view
    • Add get TriangleProperties
    • Add set ShowTriangle - only visible if you open the menu with OpenMenu
      • Default: False
  • 1.04
    • BugFix
  • 1.05
    • BugFixes
    • Add OpenMenuAdvanced - You can set the Left, Top and Width value to show the menu on the parent
  • 1.06
    • Add get BackgroundPanel
Have Fun :)
 

Attachments

  • AS PopupMenuAdvanced Example.zip
    10.4 KB · Views: 1,213
  • ASPopupMenuAdvanced.b4xlib
    4.6 KB · Views: 697
Last edited:

Alexander Stolte

Expert
Licensed User
Longtime User
In the next version, its possible to add the menu to a view like in the normal version, but in the advanced version you can put your own layout into the menu.

Sneak Preview of what is possible:
1636582606070.png

You want a nice combobox? no problem:
IMG_2058.jpg
RPReplay_Final1636584250.gif
 

Alexander Stolte

Expert
Licensed User
Longtime User
Update
  • 1.01
    • Add OpenMenuOnView - opens the view attached on a view
    • Add set IsInSpecialContainer - set it true if the target is on a listview or as a child on a panel where the left and top values differ from the form
    • Add set ActivityHasActionBar
    • Add set OrientationVertical
    • Add set MenuViewGap - sets the gap between the menu and the attached view
      • only affected if you open the menu with OpenMenuOnView
it is now possible to fix the popup menu to a view. This gives the possibility to do things like in the last comment.

ComboBox Example:
 

Ferdari

Active Member
Licensed User
Longtime User
Update
  • 1.01
    • Add OpenMenuOnView - opens the view attached on a view
    • Add set IsInSpecialContainer - set it true if the target is on a listview or as a child on a panel where the left and top values differ from the form
    • Add set ActivityHasActionBar
    • Add set OrientationVertical
    • Add set MenuViewGap - sets the gap between the menu and the attached view
      • only affected if you open the menu with OpenMenuOnView
it is now possible to fix the popup menu to a view. This gives the possibility to do things like in the last comment.

ComboBox Example:
Hi Alex, How to check if menu is open?

IsOpen Boolean
 
Last edited:

Alexander Stolte

Expert
Licensed User
Longtime User
Update
  • 1.03
    • Add set MenuViewGap - sets the gap between the menu and the attached view
    • Add get TriangleProperties
    • Add set ShowTriangle - only visible if you open the menu with OpenMenuOnView
      • Default: False
KTa7gKtcmrbG6pEHsg6rdVqCE1ChquLRGgVWzvyhxJWWJFU0wI.jpeg

Example:
B4X:
aspma_Main.MenuViewGap = aspma_Main.TriangleProperties.Height + 2dip
aspma_Main.ShowTriangle = True
aspma_Main.TriangleProperties.Left = 150dip/2 - aspma_Main.TriangleProperties.Width/2 'Middle
 
Last edited:

Ferdari

Active Member
Licensed User
Longtime User
Update
  • 1.03
    • Add set MenuViewGap - sets the gap between the menu and the attached view
    • Add get TriangleProperties
    • Add set ShowTriangle - only visible if you open the menu with OpenMenuOnView
      • Default: False
View attachment 125170
Example:
B4X:
aspma_Main.MenuViewGap = aspma_Main.TriangleProperties.Height + 2dip
aspma_Main.ShowTriangle = True
aspma_Main.TriangleProperties.Left = 150dip/2 - aspma_Main.TriangleProperties.Width/2 'Middle
Thanks for the update Alex!
 

moore_it

Well-Known Member
Licensed User
Longtime User
Hi Alexander, is possible to change the background color of the parent view during the menu is open like ASPopupMenu ?

Thanks for reply
 

Sepehr_b

Member
Hi Alex,
Thanks for this nice popup

in your PopupMenu , there is a color animated effect on the selected item background that the user get if the item is clicked.
but in PopupMenuAdvanced, it is missing.
 
Top