PopupMenu in expanded position

Hi all

I have a listbox with clickable headings. When a heading is clicked a popupmenu becomes visible, simulating a popupmenu within a listbox. In the pic below it is the column with the “Date” heading.

Once the new heading is chosen, the PopupMenu becomes invisible and then option loads into the Listbox heading.

The problem is that when the heading is clicked, the PopupMenu is visible, but in its collapsed state (because the Popupmenu itself has not been clicked).

it then takes another click on the PopupMenu itself to expand it to show the options.

Is there any way to programatically make a PopupMenu visible, active and expanded (as if it has already been clicked)?

You would not get the visual (popup active) but with some tweaking this may help. (Listbox HeaderPressed Event) Known column widths in this example.

[code]Function HeaderPressed(column as Integer) As Boolean
Dim base, selections, menuChoice As MenuItem

base = new MenuItem

selections = New MenuItem(“Date”)
base.Append selections

selections = New MenuItem(“Transaction Amount”)
base.Append selections

selections = New MenuItem(“Notes”)
base.Append selections

selections = New MenuItem(“GST”)
base.Append selections

selections = New MenuItem(“Ignore”)
base.Append selections

selections = New MenuItem(“Hide Column”)
base.Append selections

if column = 0 then

menuChoice = base.PopUp(TrueWindow.left + me.Left,TrueWindow.top + me.top)

elseif column = 1 then

menuChoice = base.PopUp(TrueWindow.left + me.Left + 120,TrueWindow.top + me.top)

elseif column = 2 then

menuChoice = base.PopUp(TrueWindow.left + me.Left + 240,TrueWindow.top + me.top)

end if

if menuChoice <> nil then

// my app specific code here

end if

Return True

End Function
[/code]

AFAIK there is no way to do that. You may want to show a ContextualMenu instead.

#if TargetCocoa Declare Sub performClick Lib "Cocoa" Selector "performClick:" (popupMenuHandle as Integer) performClick self.PopupMenu1.Handle #endif

Replace PopupMenu1 with the real name of your control…

I deploy to OS X and Windowz

Thank you all - great help!

Keep it visible all the time and set its listindex, depending on the user’s choice (save the Popupmenu1.listindex to the preferences, if necessary) .

On Windows, this code in the GotFocus event handler displays the drop-down:

[code] Soft Declare Function SendMessage Lib “user32” Alias “SendMessageA” (ByVal hwnd As Integer, _
ByVal wMsg As UInt32, _
ByVal wParam As Integer, _
param1 As Integer) As Integer

Const CB_SHOWDROPDOWN = &H14F
Const ShowDropDown = 1
Const HideDropDown = 0

Call SendMessage(Me.Handle, CB_SHOWDROPDOWN, ShowDropDown, 0)[/code]