Popup Menu - Custom, Icons, Color, Radio...

Popup menu anchored to a button. It can include text options, icons from the application's "Assets", HTML text, change the menu radius, background color and the separator line between items.

20241023_065758


Function

ShowPopupMenu

  1. anchorComponent: Button where the menu will be anchored.
  2. options: List of text options to display in the menu.
  3. icons: List of icons from Assets. If the list of icons is smaller than the list of options, the first icon is reused.
  4. backgroundColor: Background color of the menu, which accepts both hexadecimal and int formats.
  5. cornerRadius: Radius of the corners of the menu.
  6. textSize: Text size.
  7. textColor: Text color, which also accepts hexadecimal or int formats.
  8. useHtml: Boolean indicating whether text options should be interpreted as HTML or not.
  9. separatorColor: Color of the separators between the options.
  10. showAboveAnchor: Boolean to determine whether the menu should appear above or below the anchored component.

Event

PopupMenuItemSelected

  • Parámetros:
  1. item: Texto de la opción seleccionada.
  2. index: Indice de la opción seleccionada.
  3. iconPath: Ruta del icono asociado con la opción seleccionada, si hay uno disponible.

Extension:
joejsanz.joedevpopupmenu.aix (12.4 KB)


Thanks.

13 Likes

Good work, looks like a prettified version of Ulli's PopupMenu extension.

  • Does the popupmenu have to be anchored to a component? can it be positioned by coordinates or location - e.g. centre/centre
  • what happens if "showAboveAnchor" is set to false, and the anchor is at the bottom of a fixed page view
2 Likes

Thanks a lot Tim.

  • Yes, it must be anchored, it cannot be positioned by coordinates or location.

  • If "showAboveAnchor" is set to false and the anchor is at the bottom, the popup menu will not be visible, which is why I set that parameter, so it could appear at the bottom or top.
    Although now that you mention it, I think I could make it detect what position the anchor is at.

1 Like

I am using your extension with several popupmenus linked together. Works great!
But what I am missing here is a ripple effect when an item gets clicked.
I can add this for you if you like (when you give me the source code)

Hi.
I'm testing the extension, it's very nice and usable.
I'm having problems with Kodular: everything works fine in Companion, but building the APK gives errors.
There are only 2 blocks!
I'm attaching the file with the build logs.
If it works in Kodular, I can pay you.
Thanks.

error_build_apk.txt (5.4 KB)

What about providing the complete error log here?

Taifun

Here you are:

Kodular is unable to compile this project.
The compiler error output was
[ReadBuildInfo] Starting Task
[ReadBuildInfo] Task succeeded in 0.006 seconds
[LoadComponentInfo] Starting Task
[LoadComponentInfo] INFO: Generating assets...
[LoadComponentInfo] Component assets needed, n = 7
[LoadComponentInfo] INFO: Generating activities...
[LoadComponentInfo] Component activities needed, n = 0
[LoadComponentInfo] INFO: Component "joejsanz.joedevpopupmenu.JoeDevPopupMenu" does not specify activityMetadata
[LoadComponentInfo] Component activity metadata needed, n = 0
[LoadComponentInfo] INFO: Generating broadcast receivers...
[LoadComponentInfo] INFO: Component "joejsanz.joedevpopupmenu.JoeDevPopupMenu" does not specify broadcastReceivers
[LoadComponentInfo] INFO: Component "joejsanz.joedevpopupmenu.JoeDevPopupMenu" does not specify contentProviders
[LoadComponentInfo] INFO: Generating libraries...
[LoadComponentInfo] INFO: Component "joejsanz.joedevpopupmenu.JoeDevPopupMenu" does not specify libraries
[LoadComponentInfo] Libraries needed, n = 4
[LoadComponentInfo] INFO: Component "joejsanz.joedevpopupmenu.JoeDevPopupMenu" does not specify metadata
[LoadComponentInfo] Component metadata needed, n = 0
[LoadComponentInfo] INFO: Generating Android minimum SDK...
[LoadComponentInfo] INFO: Generating native libraries...
[LoadComponentInfo] INFO: Component "joejsanz.joedevpopupmenu.JoeDevPopupMenu" does not specify native
[LoadComponentInfo] Native Libraries needed, n = 0
[LoadComponentInfo] INFO: Generating permissions...
[LoadComponentInfo] usesLocation = False
[LoadComponentInfo] Permissions needed, n = 4
[LoadComponentInfo] INFO: Component "joejsanz.joedevpopupmenu.JoeDevPopupMenu" does not specify queries
[LoadComponentInfo] INFO: Component "joejsanz.joedevpopupmenu.JoeDevPopupMenu" does not specify services
[LoadComponentInfo] INFO: Component "joejsanz.joedevpopupmenu.JoeDevPopupMenu" does not specify xmls
[LoadComponentInfo] Component xmls needed, n = 0
[LoadComponentInfo] INFO: Generating component broadcast receivers...
[LoadComponentInfo] INFO: Component "joejsanz.joedevpopupmenu.JoeDevPopupMenu" does not specify broadcastReceiver
[LoadComponentInfo] Task succeeded in 0.011 seconds
[CheckDeprecatedComponents] Starting Task
[CheckDeprecatedComponents] Task succeeded in 0.024 seconds
[CheckComponentRequirements] Starting Task
[CheckComponentRequirements] Task succeeded in 0.0 seconds
[VerifyExtensions] Starting Task
[VerifyExtensions] Task succeeded in 0.088 seconds
[GenerateBuildId] Starting Task
[GenerateBuildId] INFO: Skipping Build ID generation for App with no required components.
[GenerateBuildId] Task succeeded in 0.0 seconds
[RetrieveGamAdUnit] Starting Task
[RetrieveGamAdUnit] INFO: Skipping Ad Unit ID retrieval for app with no required components.
[RetrieveGamAdUnit] Task succeeded in 0.0 seconds
[PrepareAppIcon] Starting Task
[PrepareAppIcon] INFO: Creating mipmap dirs...
[PrepareAppIcon] INFO: Generating icons...
[PrepareAppIcon] Generating icons for mipmap-mdpi
[PrepareAppIcon] Generating icons for mipmap-hdpi
[PrepareAppIcon] Generating icons for mipmap-xhdpi
[PrepareAppIcon] Generating icons for mipmap-xxhdpi
[PrepareAppIcon] Generating icons for mipmap-xxxhdpi
[PrepareAppIcon] Task succeeded in 0.08 seconds
[XmlConfig] Starting Task
[XmlConfig] INFO: Creating animation xml
[XmlConfig] Creating zoom_enter.xml
[XmlConfig] Creating fadeout.xml
[XmlConfig] Creating slide_v_exit.xml
[XmlConfig] Creating fadein.xml
[XmlConfig] Creating zoom_exit.xml
[XmlConfig] Creating slide_v_enter.xml
[XmlConfig] Creating zoom_exit_reverse.xml
[XmlConfig] Creating slide_v_enter_reverse.xml
[XmlConfig] Creating zoom_enter_reverse.xml
[XmlConfig] Creating slide_enter_reverse.xml
[XmlConfig] Creating slide_exit.xml
[XmlConfig] Creating hold.xml
[XmlConfig] Creating slide_enter.xml
[XmlConfig] Creating slide_v_exit_reverse.xml
[XmlConfig] Creating slide_exit_reverse.xml
[XmlConfig] INFO: Creating colors xml
[XmlConfig] INFO: Creating styles xml
[XmlConfig] INFO: Creating provider_path xml
[XmlConfig] INFO: Creating network_security_config xml
[XmlConfig] INFO: Generating adaptive icon file
[XmlConfig] INFO: Generating round adaptive icon file
[XmlConfig] INFO: Generating adaptive icon background file
[XmlConfig] INFO: Creating fragment xml
[XmlConfig] INFO: Creating listview xml
[XmlConfig] INFO: Creating listview-21 xml
[XmlConfig] INFO: Creating drawable xml
[XmlConfig] INFO: Creating drawable-21 xml
[XmlConfig] INFO: Creating strings xml
[XmlConfig] Task succeeded in 0.003 seconds
[CreateManifest] Starting Task
[CreateManifest] INFO: Reading project specs...
[CreateManifest] VCode: 1
[CreateManifest] VName: 1.0
[CreateManifest] Custom Package Name: io.kodular.usr_q04k0k4qfc8uc40yjqa7.popup_menu1
[CreateManifest] Min SDK 21
[CreateManifest] INFO: Writing screen 'io.kodular.henryferrets.popup_menu1.Screen1'
[CreateManifest] Task succeeded in 0.001 seconds
[AttachNativeLibs] Starting Task
[AttachNativeLibs] Task succeeded in 0.0 seconds
[AttachAarLibs] Starting Task
[AttachAarLibs] Task succeeded in 0.06 seconds
[AttachCompAssets] Starting Task
[AttachCompAssets] Task succeeded in 0.003 seconds
[MergeResources] Starting Task
[MergeResources] Task succeeded in 0.062 seconds
[SetupLibs] Starting Task
[SetupLibs] Task succeeded in 0.0 seconds
[RunAapt] Starting Task
[RunAapt] ERROR: Error running AAPT
[RunAapt] Task errored in 0.237 seconds
.

I replicated your blocks in AppInventor and was able to compile the project without issue

1 Like

That's strange, I've tried the same two blocks in Kodular and it compiles fine.
Here's the AIA project for you to try.

PopupMenu.aia (26.3 KB)

1 Like

Thanks @Taifun
Thanks @TIMAI2
Thanks @Joejsanz

I redid a new project and it works!
I checked the old project, and in the settings, under the 'Theme' section, the colors were no longer there... and if I click to edit, the error appears.
I actually checked the project settings, but... I skipped the 'Theme' section, so I didn't notice! :slight_smile:
I don't know why those fields are in that state.
Thanks everyone.
Enrico