B4A Class [B4X] [XUI] AS Popup Menu

This is a simple cross platform Popup Menu.

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. :)

Left: B4J Right: B4A

1598981805790.png
Screenshot_20200901-193834.jpg
ezgif.com-resize.gif
Screenshot_20201124-140900.jpg
IMG_2331.jpg
KTa7gKtcmrbG6pEHsg6rdVqCE1ChquLRGgVWzvyhxJWWJFU0wI.jpeg

(54) mage.png

Fast example:
aspm_MoreOptions.Initialize(Root,Me,"aspm_MoreOptions")
 
aspm_MoreOptions.ItemLabelProperties.ItemBackgroundColor = xui.Color_ARGB(255,19, 20, 22) 'Change the Background Color of the item
aspm_MoreOptions.AddMenuItem("Share location",1)'Add item
aspm_MoreOptions.AddMenuItem("Settings",2)'Add item

aspm_MoreOptions.OrientationHorizontal = aspm_MoreOptions.OrientationHorizontal_RIGHT
aspm_MoreOptions.OrientationVertical = aspm_MoreOptions.OrientationVertical_BOTTOM
 
aspm_MoreOptions.ItemLabelProperties.BackgroundColor = xui.Color_ARGB(200,0,0,0)'black
 
aspm_MoreOptions.OpenMenu(xlbl_MoreOptions,150dip)
ASPopupMenu
Author: Alexander Stolte
Version: 1.08

  • ASPM_ItemLabelProperties
    • Fields:
      • BackgroundColor As Int
      • 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.
  • ASPM_TitleLabelProperties
    • 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.
  • ASPopupMenu
    • Events:
      • ItemClicked (Index As Int, Tag As Object)
    • Fields:
      • AutoHideMs As Int
      • CloseDurationMs As Int
      • OpenDurationMs As Int
    • Functions:
      • AddMenuItem (text As String, tag As Object) As String
      • AddTitle (Text As String, height As Float) As String
      • Class_Globals As String
      • Clear As String
        clears the list
      • CloseMenu As String
      • CreateASPM_ItemLabelProperties (TextColor As Int, xFont As B4XFont, TextAlignment_Vertical As String, TextAlignment_Horizontal As String, BackgroundColor As Int, ItemBackgroundColor As Int, LeftRightPadding As Float) As ASPM_ItemLabelProperties
      • CreateASPM_TitleLabelProperties (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_TitleLabelProperties
      • getBase As B4XView
      • getisOpen As Boolean
        checks if the menu is open
      • getItemLabelProperties As ASPM_ItemLabelProperties
        change the label properties, call it before you add items
        <code>ASScrollingTags1.LabelProperties.xFont = xui.CreateDefaultBoldFont(15)</code>
      • GetMenuItemAt_Background (index As Int) As B4XView
        gets a menu item background (parent of label)
      • GetMenuItemAt_Label (index As Int) As B4XView
        gets a menu item label - the label with the text
      • 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
      • getSize As Int
        gets the list size
      • getTitleLabelProperties As ASPM_TitleLabelProperties
        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 (view As B4XView, width As Float)
        Opens the menu on a view
      • OpenMenu2 (parent As B4XView, width As Float)
        Open the menu on center of parent/view
      • RemoveTitle As String
        Removes the title if exists
      • Resize (parent_width As Float, parent_height As Float) As String
      • setActivityHasActionBar (value As Boolean) As String
      • setCloseAfterItemClick (enabled As Boolean) As String
        closes the menu automatically after clicking on an item
        standard is True
      • setDividerColor (color As Int) As String
        the color of the dividers
      • setDividerEnabled (enable As Boolean) As String
        Adds or Removes the dividers
      • setDividerHeight (height As Float) As String
        the height of the dividers
      • 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
      • setItemBackgroundColor (crl As Int) As String
        sets the item background color for all items
      • setMenuCornerRadius (radius As Int) As String
      • setOrientationHorizontal (orientation As String) As String
      • setOrientationVertical (orientation As String) As String
      • ViewScreenPosition (view As B4XView) As Int()
    • Properties:
      • ActivityHasActionBar
      • Base As B4XView [read only]
      • CloseAfterItemClick
        closes the menu automatically after clicking on an item
        standard is True
      • DividerColor
        the color of the dividers
      • DividerEnabled
        Adds or Removes the dividers
      • DividerHeight
        the height of the dividers
      • 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
      • isOpen As Boolean [read only]
        checks if the menu is open
      • ItemBackgroundColor
        sets the item background color for all items
      • ItemLabelProperties As ASPM_ItemLabelProperties [read only]
        change the label properties, call it before you add items
        <code>ASScrollingTags1.LabelProperties.xFont = xui.CreateDefaultBoldFont(15)</code>
      • MenuCornerRadius
      • OrientationHorizontal
      • 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
      • Size As Int [read only]
        gets the list size
      • TitleLabelProperties As ASPM_TitleLabelProperties [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
    • Adds background_color global variable - the background color of the parent view during the menu is open
    • Adds setItemBackgroundColor - change the items background color
    • Better Handling in "Nested Layouts"
    • Add ActivityHasActionBar - set to true if you have a ActionBar enabled
    • Add 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 setOrientationVertical
    • Add setOrientationHorizontal
    • Adds "Enums" for Orientations -TOP,BOTTOM -LEFT,MIDDLE,RIGHT
  • 1.02
    • Add OpenMenu2 - Opens the menu in center of the parent view
    • Add Clear - clear all
    • Add getBase - gets the base view to customize it
    • Add getLabelProperties - customize it if you want, before you add a new menu item
      • Screenshot_20201124-134749.jpg
      • this is now possible
        • aspm_main.LabelProperties.ItemBackgroundColor = xui.Color_ARGB(255,Rnd(1,256), Rnd(1,256), Rnd(1,256))
    • Remove background_color and itembackground_color
      • Added to getLabelProperties
    • Add GetMenuItemAt_Label
    • Add GetMenuItemAt_Background
    • Add getSize
    • Add setMenuCornerRadius - sets the corner radius for the menu (works only in B4A and B4I)
      • Screenshot_20201124-140900.jpg
  • 1.03
    • Add LeftRightPadding to ASPM_LabelProperties - label padding to have more space left and right for example HorizontalCenter = LEFT
    • OpenMenu the background is now smoother on show
    • setMenuCornerRadius is now available on B4J (thanks @Erel)
  • 1.04
    • getLabelProperties is renamed to getItemLabelProperties
    • Add AddTitle - you can now add a title to the menu
      • Add TitleLabelProperties - you can change the title properties with it
    • Add RemoveTitle - Removes the title if exists
    • Add AutoHideMs
    • Add DividerEnabled - you can now show dividers between the items
      • Add DividerHeight - the height of the dividers
      • Add DividerColor - the color of the dividers
  • 1.05
    • OpenMenu Show Animation with the background is now animated
    • BugFixes
  • 1.06
    • BugFixes
  • 1.07
    • Add get isOpen - checks if the menu is open
    • BugFix - if you called OpenMenu several times without closing the menu, then the menu was added several times
    • Add set CloseAfterItemClick - closes the menu automatically after clicking on an item
      • standard is True
    • Add set and get CloseDurationMs - the duration it takes for the menu to be completely closed
    • Add set and get OpenDurationMs - the duration it takes for the menu to be fully visible
  • 1.08
    • Intern Function IIF renamed to iif2
  • 1.09
    • 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.10
    • BugFix
  • 1.11
    • Add OpenMenuAdvanced - You can set the Left, Top and Width value to show the menu on the parent
    • Add MenuHeight - gets the MenuHeight even if the menu is not yet visible
    • BugFixes
  • 1.12 (read more)
    • Add get and set ClickColor
    • Add get and set BackgroundPanelColor
    • B4J Only - Hover Over Item with color
  • 1.13 (read more)
    • Add AddMenuItemWithIcon
    • Add get IconProperties
    • Add get and set ItemHeight
  • 1.14
    • Text can now be multiline
  • 1.15
    • B4I Improvements - the entire screen is now used for the background shadow
      • When the navigation bar was hidden, there was an area at the top that did not go dark when the menu was opened
      • The height of the area is now determined and the gap closed
      • B4XPages is now required in B4I
Have Fun :)
 

Attachments

  • AS PopupMenu Example.zip
    10.5 KB · Views: 1,187
  • ASPopupMenu.b4xlib
    7.3 KB · Views: 21
Last edited:

endbyte

Member
At the bottom of my application there is a panel with several buttons, I put a menu button on the left side of that panel, but when I press the button so that the menu appears, it appears but on the top edge of my application, I have tried to Anyway so that it appears right on the menu button(BMMenus2) but I can't do it, please tell me what I'm doing wrong, this is the configuration of my menu and the code where I call it from the button:

B4X:
'*************** CONFIGURACION DE MENU *****
aspm.Initialize(Activity,Me,"aspm")
aspm.ActivityHasActionBar = False
aspm.OrientationVertical = aspm.OrientationVertical_TOP
aspm.Orientationhorizontal = aspm.OrientationHorizontal_LEFT
aspm.ItemLabelProperties.BackgroundColor = XUI.Color_ARGB(100,0,0,0)'black
aspm.DividerEnabled = True
aspm.DividerHeight = 1dip
aspm.DividerColor = XUI.Color_white
aspm.TitleLabelProperties.BackgroundColor = XUI.Color_White
aspm.TitleLabelProperties.TextColor = XUI.Color_Black
aspm.TitleLabelProperties.xFont = XUI.CreateDefaultBoldFont(12)
aspm.AddTitle("opciones de entrada",45dip)
aspm.MenuCornerRadius = 5dip
aspm.ItemLabelProperties.ItemBackgroundColor = XUI.Color_ARGB(255,150, 150, 150)
aspm.ItemLabelProperties.xFont=XUI.CreateDefaultFont(12)
aspm.ItemLabelProperties.TextColor = XUI.Color_ARGB(255,0,0,0)
aspm.AddMenuItem("Guardar movimiento", 0)
aspm.AddMenuItem("Copiar movimiento", 1)
aspm.AddMenuItem("Borrar movimiento", 2)
aspm.AddMenuItem("Agregar entrada", 3)


Sub BMMenus2_Click
    aspm.OpenMenu(BMMenus2,200dip)
End Sub
 
Last edited:

endbyte

Member
I corrected it by changing this line, I did several tests putting views with top vertical orientation menu and it works well on vertical and horizontal screen, thanks, very useful library. I'm really liking b4a.

B4X:
Private Sub GetTopLeft(top As Float,left As Float,width As Float,view As B4XView)
    If top < 0 Then
        top = view.Top + view.Height
    Else If (top + xpnl_background.Height) > max_y Then
        'top = view.Top - xpnl_background.Height
        top = view.Top - xpnl_background.Height + view.Height 'CHANGE OF LINE
    Else If left < 0 Then
        left = 0
    Else If (left + width) > max_x Then
        left = max_x - width
    Else
        CallSubDelayed3(Me,"lol",left,top)
        Return
    End If
    If max_endlessloop = 10 Then
        CallSubDelayed3(Me,"lol",left,top)
        Return
    End If
    max_endlessloop = max_endlessloop +1
    GetTopLeft(top,left,width,view)
End Sub
 
Last edited:

mfstuart

Active Member
Licensed User
Longtime User
This is a simple cross platform Popup Menu.

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. :)

Left: B4J Right: B4A

View attachment 99402View attachment 99404View attachment 99405View attachment 103495View attachment 107567
ASPopupMenu
Author: Alexander Stolte
Version: 1.08

  • ASPM_ItemLabelProperties
    • Fields:
      • BackgroundColor As Int
      • 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.
  • ASPM_TitleLabelProperties
    • 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.
  • ASPopupMenu
    • Events:
      • ItemClicked (Index As Int, Tag As Object)
    • Fields:
      • AutoHideMs As Int
      • CloseDurationMs As Int
      • OpenDurationMs As Int
    • Functions:
      • AddMenuItem (text As String, tag As Object) As String
      • AddTitle (Text As String, height As Float) As String
      • Class_Globals As String
      • Clear As String
        clears the list
      • CloseMenu As String
      • CreateASPM_ItemLabelProperties (TextColor As Int, xFont As B4XFont, TextAlignment_Vertical As String, TextAlignment_Horizontal As String, BackgroundColor As Int, ItemBackgroundColor As Int, LeftRightPadding As Float) As ASPM_ItemLabelProperties
      • CreateASPM_TitleLabelProperties (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_TitleLabelProperties
      • getBase As B4XView
      • getisOpen As Boolean
        checks if the menu is open
      • getItemLabelProperties As ASPM_ItemLabelProperties
        change the label properties, call it before you add items
        <code>ASScrollingTags1.LabelProperties.xFont = xui.CreateDefaultBoldFont(15)</code>
      • GetMenuItemAt_Background (index As Int) As B4XView
        gets a menu item background (parent of label)
      • GetMenuItemAt_Label (index As Int) As B4XView
        gets a menu item label - the label with the text
      • 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
      • getSize As Int
        gets the list size
      • getTitleLabelProperties As ASPM_TitleLabelProperties
        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 (view As B4XView, width As Float)
        Opens the menu on a view
      • OpenMenu2 (parent As B4XView, width As Float)
        Open the menu on center of parent/view
      • RemoveTitle As String
        Removes the title if exists
      • Resize (parent_width As Float, parent_height As Float) As String
      • setActivityHasActionBar (value As Boolean) As String
      • setCloseAfterItemClick (enabled As Boolean) As String
        closes the menu automatically after clicking on an item
        standard is True
      • setDividerColor (color As Int) As String
        the color of the dividers
      • setDividerEnabled (enable As Boolean) As String
        Adds or Removes the dividers
      • setDividerHeight (height As Float) As String
        the height of the dividers
      • 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
      • setItemBackgroundColor (crl As Int) As String
        sets the item background color for all items
      • setMenuCornerRadius (radius As Int) As String
      • setOrientationHorizontal (orientation As String) As String
      • setOrientationVertical (orientation As String) As String
      • ViewScreenPosition (view As B4XView) As Int()
    • Properties:
      • ActivityHasActionBar
      • Base As B4XView [read only]
      • CloseAfterItemClick
        closes the menu automatically after clicking on an item
        standard is True
      • DividerColor
        the color of the dividers
      • DividerEnabled
        Adds or Removes the dividers
      • DividerHeight
        the height of the dividers
      • 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
      • isOpen As Boolean [read only]
        checks if the menu is open
      • ItemBackgroundColor
        sets the item background color for all items
      • ItemLabelProperties As ASPM_ItemLabelProperties [read only]
        change the label properties, call it before you add items
        <code>ASScrollingTags1.LabelProperties.xFont = xui.CreateDefaultBoldFont(15)</code>
      • MenuCornerRadius
      • OrientationHorizontal
      • 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
      • Size As Int [read only]
        gets the list size
      • TitleLabelProperties As ASPM_TitleLabelProperties [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
    • Adds background_color global variable - the background color of the parent view during the menu is open
    • Adds setItemBackgroundColor - change the items background color
    • Better Handling in "Nested Layouts"
    • Add ActivityHasActionBar - set to true if you have a ActionBar enabled
    • Add 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 setOrientationVertical
    • Add setOrientationHorizontal
    • Adds "Enums" for Orientations -TOP,BOTTOM -LEFT,MIDDLE,RIGHT
  • 1.02
    • Add OpenMenu2 - Opens the menu in center of the parent view
    • Add Clear - clear all
    • Add getBase - gets the base view to customize it
    • Add getLabelProperties - customize it if you want, before you add a new menu item
      • View attachment 103494
      • this is now possible
        • aspm_main.LabelProperties.ItemBackgroundColor = xui.Color_ARGB(255,Rnd(1,256), Rnd(1,256), Rnd(1,256))
    • Remove background_color and itembackground_color
      • Added to getLabelProperties
    • Add GetMenuItemAt_Label
    • Add GetMenuItemAt_Background
    • Add getSize
    • Add setMenuCornerRadius - sets the corner radius for the menu (works only in B4A and B4I)
  • 1.03
    • Add LeftRightPadding to ASPM_LabelProperties - label padding to have more space left and right for example HorizontalCenter = LEFT
    • OpenMenu the background is now smoother on show
    • setMenuCornerRadius is now available on B4J (thanks @Erel)
  • 1.04
    • getLabelProperties is renamed to getItemLabelProperties
    • Add AddTitle - you can now add a title to the menu
      • Add TitleLabelProperties - you can change the title properties with it
    • Add RemoveTitle - Removes the title if exists
    • Add AutoHideMs
    • Add DividerEnabled - you can now show dividers between the items
      • Add DividerHeight - the height of the dividers
      • Add DividerColor - the color of the dividers
  • 1.05
    • OpenMenu Show Animation with the background is now animated
    • BugFixes
  • 1.06
    • BugFixes
  • 1.07
    • Add get isOpen - checks if the menu is open
    • BugFix - if you called OpenMenu several times without closing the menu, then the menu was added several times
    • Add set CloseAfterItemClick - closes the menu automatically after clicking on an item
      • standard is True
    • Add set and get CloseDurationMs - the duration it takes for the menu to be completely closed
    • Add set and get OpenDurationMs - the duration it takes for the menu to be fully visible
  • 1.08
    • Intern Function IIF renamed to iif2
Have Fun :)
I downloaded your b4a example and unzipped it into a folder.
When loading the B4A project, it shows the following message:

[IDE message - 7:55:13]
The following modules are missing:
C:\Projects\B4A\ASPopupMenu.bas

It definitely is missing from the example project.

Could you please correct it and re-upload?

Thanx,
Mark Stuart
 

Rubsanpe

Active Member
Licensed User
I downloaded your b4a example and unzipped it into a folder.
When loading the B4A project, it shows the following message:

[IDE message - 7:55:13]
The following modules are missing:
C:\Projects\B4A\ASPopupMenu.bas

It definitely is missing from the example project.

Could you please correct it and re-upload?

Thanx,
Mark Stuart
Hi, you need download and use the b4xlib from first post.

Rubén
 

mfstuart

Active Member
Licensed User
Longtime User
Hi, you need download and use the b4xlib from first post.

Rubén
I had put it in the Additional Libraries folder instead of the Libraries folder.
And I had to reselect the library in the project.
Thanx for your help.
Mark Stuart
 

AlexMaa

Member
Licensed User
Longtime User
 

Alexander Stolte

Expert
Licensed User
Longtime User
Update
  • 1.09
    • 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
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

Can you add something like the image below ??
yes
 

james_sgp

Active Member
Licensed User
Longtime User
B4i sample is crashing for me on iOS15.2, menu appears when I click on the button, any subsequent click crashes.

B4X:
Copying updated assets files (1)
Application_Start
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
Application_Active
Error occurred on line: 529 (ASPopupMenu)
Object was not initialized (UIView)
Stack Trace: (
  CoreFoundation       __exceptionPreprocess + 242
  libobjc.A.dylib      objc_exception_throw + 48
  CoreFoundation       -[NSException initWithCoder:] + 0
  B4i Example          -[B4IObjectWrapper object] + 111
  B4i Example          -[B4XViewWrapper setVisible:] + 40
  B4i Example          -[b4i_aspopupmenu _closemenu:] + 379
  B4i Example          -[b4i_aspopupmenu _xpnl_touch_click:] + 301
  CoreFoundation       __invoking___ + 140
  CoreFoundation       -[NSInvocation invoke] + 305
  B4i Example          +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1519
 B4i Example          -[B4IShell runMethod:] + 380
 B4i Example          -[B4IShell raiseEventImpl:method:args::] + 1566
 B4i Example          -[B4IShellBI raiseEvent:event:params:] + 1358
 B4i Example          __33-[B4I raiseUIEvent:event:params:]_block_invoke + 51
 libdispatch.dylib    _dispatch_call_block_and_release + 12
 libdispatch.dylib    _dispatch_client_callout + 8
 libdispatch.dylib    _dispatch_main_queue_callback_4CF + 1075
 CoreFoundation       __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
 CoreFoundation       __CFRunLoopRun + 2772
 CoreFoundation       CFRunLoopRunSpecific + 567
 GraphicsServices     GSEventRunModal + 139
 UIKitCore            -[UIApplication _run] + 928
 UIKitCore            UIApplicationMain + 101
 B4i Example          main + 104
 dyld                 start_sim + 10
 ???                  0x0 + 1
)
 

james_sgp

Active Member
Licensed User
Longtime User
Hi,

I`m now also getting an error in the B4A version too, seems to be the same as the B4i error I mentioned earlier. Can you advise what issue is? :
B4X:
Error occurred on line: 529 (ASPopupMenu)
java.lang.RuntimeException: Object should first be initialized (B4XView).
    at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:67)
    at anywheresoftware.b4a.objects.B4XViewWrapper.asViewWrapper(B4XViewWrapper.java:89)
    at anywheresoftware.b4a.objects.B4XViewWrapper.setVisible(B4XViewWrapper.java:115)
    at com.as.popupmenu.aspopupmenu._closemenu(aspopupmenu.java:1456)
    at com.as.popupmenu.aspopupmenu._clickitem(aspopupmenu.java:1376)
    at com.as.popupmenu.aspopupmenu._item_click(aspopupmenu.java:1938)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
    at android.view.View.performClick(View.java:8160)
    at android.view.View.performClickInternal(View.java:8137)
    at android.view.View.access$3700(View.java:888)
    at android.view.View$PerformClick.run(View.java:30236)
    at android.os.Handler.handleCallback(Handler.java:938)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:246)
    at android.app.ActivityThread.main(ActivityThread.java:8653)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
** Activity (main) Pause event (activity is not paused). **
** Service (starter) Destroy (ignored)**
 

Alexander Stolte

Expert
Licensed User
Longtime User
Update
  • 1.11
    • Add OpenMenuAdvanced - You can set the Left, Top and Width value to show the menu on the parent
    • Add MenuHeight - gets the MenuHeight even if the menu is not yet visible
    • BugFixes
Example project where the new props. are used:
 

Daica

Active Member
Licensed User
I noticed that when you use Open2(Root, 250dip) and have 6+ items, the popup goes up further and further on the screen instead of being in the center.

I use the OpenMenuAdvance to center the menu instead but just wanted to let you know
 
Last edited:

Daica

Active Member
Licensed User
Hi Alex, do you think it would be possible to add an option to add more than 1 title to the pop up so tat we could maybe split the popup into sections?

For example:

Section 1 [Title]
Item 1
Item 2
Section 2 [Title]
Item 1
Item 2
 
Top