How? Presenting a popup menu

In a Desktop project, I would like the user to be able to left-click a PopupArrow, and have a menu presented. I figured out the context (right) click, but can’t seem to figure out how to present a menu with a left click. Use case is an integer text field with a PopupArrow next to it that lets user select some default numbers. Think port numbers for a well-known protocol.

Why not just use a combo box?

I must be missing something… can’t you just use MenuItem.popup(X,Y) in it’s mousedown event?

on MouseDown event:

dim m as new menuItem

dim m1 as new menuitem(“test”)
m.append m1

dim m2 as new menuitem(“test 2”)
m.append m2

dim mm as menuitem = m.popUp

No, that would be missing something. Thank you both.

I have code like that in Massimo’s post in the CellClick event of a ListBox. The popup menu works just fine in Carbon, but I can’t get the menu to enable in Cocoa (RS2012r2), even by subclassing the MenuItem and setting Enabled=true in the EnableMenuItem event. Is there a trick to this, or is that a Cocoa bug in that version of RS?

Answering my own question, above: the problem with non-enabled popup menus in Cocoa is specific to RS2012r2. In the current version of Xojo it works just fine.