B4A Class [B4X] [XUI] AS Popup Menu

Alexander Stolte

Expert
Licensed User
Longtime User
aspm_main.TitleLabelProperties.BackgroundColor = xui.Color_Gray
is now fixed.
this color is automatically also set on the background at the title.
aspm_main.TitleLabelProperties.ItemBackgroundColor = xui.Color_Gray
is actually not needed, I think I will remove it soon
 

Daica

Active Member
Licensed User
I'm trying to use this popup menu together with your tab menu but I'm getting an error about type mismatch.

B4X:
aspm.Initialize(B4XTable1, Me, "tbl_menu")

If I try to use the Activity as the parent, the app crash with the following error:
B4X:
aspm.Initialize(Me, Me, "tbl_menu")
aspm.OpenMenu2(Me, 100dip)

 
Last edited:

Alexander Stolte

Expert
Licensed User
Longtime User
Under the hood you need a panel.
Because i add my base panel to the parent panel.

I dont know about the B4XTable1, but it should be something like this: B4XTable1.base or B4XTable1.mBase
 

Daica

Active Member
Licensed User
I added a transparent panel onto my layout and used that as the parent. It works, but the popup is cut off. I think I might have to add a transparent button on that panel so the popup doesn't get cut off, unless I can position the popup somehow?
 

Alexander Stolte

Expert
Licensed User
Longtime User
This is because your parent is not big enough. Either you set a bigger panel, or you set the activity/root panel, then you are on the safe side.
On "OpenMenu" you set the view where you want to see the popup.
 

Daica

Active Member
Licensed User
Yeah I had to use a transparent panel as the parent, and then put another transparent view on that panel where I want to show the menu. It works this way.

For some reason, the last item on the menu cannot be clicked on though. Do you know what might be causing that?
EDIT:
Using your example project, it works fine. I guess it must be something I am doing with my panel
 
Last edited:

Alexander Stolte

Expert
Licensed User
Longtime User
For some reason, the last item on the menu cannot be clicked on though. Do you know what might be causing that?
In B4I and B4J, your transparent panel may intercept the events. On B4A it can only be if there is a view above the popup menu which also listens to click events.
 

Daica

Active Member
Licensed User
In B4I and B4J, your transparent panel may intercept the events. On B4A it can only be if there is a view above the popup menu which also listens to click events.

I think it may have been my transparent button that is taking the click event away from the last item then. I think I will just create a button that is 1x1 in dimension through code and place it on my transparent panel, then set the menu to open where the 1x1 button is so its not big enough to take away the click
 

Noelkman

Member
Licensed User
Longtime User
Shouldn't the menu close automatically on Item Select? Actually it does not.
If I don't call [...].CloseMenu the menu stays open. If you then call [...].OpenMenu() again the parent view gets darker and darker until black out.
I used the example from the first post.
 

Alexander Stolte

Expert
Licensed User
Longtime User
Shouldn't the menu close automatically on Item Select?
I've always wondered about that, too. Are there usecases where this cannot be the case?
I'll write it down and add it to the next update.
If you then call [...].OpenMenu() again the parent view gets darker and darker until black out.
I'll write it down and fix it with the next update.
 

Daica

Active Member
Licensed User
I've always wondered about that, too. Are there usecases where this cannot be the case?
I'll write it down and add it to the next update.

I'll write it down and fix it with the next update.

Also, similar to your DraggableBottomCard, adding IsOpen as Boolean would be very helpful
Maybe instead of making the menu close automatically after clicking the item, make it an option like Menu.CloseAfterItemClick As Boolean and set it to true. Anyone who do not want the menu to close can set it to false
 
Last edited:

Alexander Stolte

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

Kope

Active Member
Licensed User
Longtime User
Hi, thanks for this library

am currently not using b4x pages and it kinda hard using this library especially this line
aspm_main.Initialize(Root,Me,"aspm_main")

How can the aspopupmenu be initiatize?

Thank You
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…