Number of menu items in bevel


I must use a bevel with menu items. With a popup I can read the number of items. With bevels I didn’t found a corresponding property. The only way I see now is to loop through the elements and wait for an exception.

But I think this is not a good way. So my question is, if someone has another idea.

As you are in control of what items are in the menu, you can store that information somewhere and avoid exceptions.

However, I would very much so recommend against BevelButton. If you’re curious to the details, I can delve into that. If you share your interface, I can make recommendations for other controls.

The reason I need a bevel Button is, that I need a popup menu without text. This works with macOS, Windows. With Linux it worked fine till GTK3. I set the width to a value, that only the arrow is visible. With GTK 3 this works not more. So I must replace the popup with the bevel.

Interface design and user experience change from app to app, so I can not make useful recommendations without seeing the whole picture.

That’s okay though, the original question was how do you know the number of items. The answer is that you must track it when you add them. You could subclass the control to extend the functionality (I would take this route), or a use property on the window to store the information.

Edit: Reworded, who starts a sentence with “because”

Because you are awesome! :smiley:


thank you for the answers. A good idea was subclassing.