# PopupMenu in expanded position

**URL:** <https://forum.xojo.com/t/popupmenu-in-expanded-position/25408>\
**Category:** General\
**Created:** [July 10, 2015, 12:30am UTC](https://forum.xojo.com/t/popupmenu-in-expanded-position/25408 "2015-07-10T00:30:11Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rob\_Lang](https://forum.xojo.com/user_avatar/forum.xojo.com/rob_lang/32/992_2.png) [@Rob\_Lang](https://forum.xojo.com/u/Rob_Lang)\
**Post date:** [July 10, 2015, 12:30am UTC](https://forum.xojo.com/t/popupmenu-in-expanded-position/25408/1 "2015-07-10T00:30:11Z")

</div>

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.

![](https://lh3.googleusercontent.com/hLb1xEVKIkKrj9tJurXIVeDTFupaGnfCbmL1CuLHJZA=w1392-h957-no)

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.

![](https://lh3.googleusercontent.com/qem50afEaE_630_Velj50JxRETqHW5dfS0JWoopak8o=w1278-h841-no)

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

---

<div class="post-metadata">

**Author:** ![Peter\_Fargo](https://forum.xojo.com/user_avatar/forum.xojo.com/peter_fargo/32/977_2.png) [@Peter\_Fargo](https://forum.xojo.com/u/Peter_Fargo)\
**Post date:** [July 10, 2015, 8:30am UTC](https://forum.xojo.com/t/popupmenu-in-expanded-position/25408/2 "2015-07-10T08:30:21Z")

</div>

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]

---

<div class="post-metadata">

**Author:** ![Michel\_Bujardet](https://forum.xojo.com/user_avatar/forum.xojo.com/michel_bujardet/32/252_2.png) [@Michel\_Bujardet](https://forum.xojo.com/u/Michel_Bujardet)\
**Post date:** [July 10, 2015, 8:52am UTC](https://forum.xojo.com/t/popupmenu-in-expanded-position/25408/3 "2015-07-10T08:52:55Z")

</div>

> [@199466:@Rob Lang](#):
>
> Is there any way to programatically make a PopupMenu visible, active and expanded (as if it has already been clicked)?

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

---

<div class="post-metadata">

**Author:** ![shao\_sean](https://forum.xojo.com/letter_avatar_proxy/v4/letter/s/ed8c4c/32.png) [@shao\_sean](https://forum.xojo.com/u/shao_sean)\
**Post date:** [July 10, 2015, 9:02am UTC](https://forum.xojo.com/t/popupmenu-in-expanded-position/25408/4 "2015-07-10T09:02:47Z")

</div>

` #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…

---

<div class="post-metadata">

**Author:** ![Rob\_Lang](https://forum.xojo.com/user_avatar/forum.xojo.com/rob_lang/32/992_2.png) [@Rob\_Lang](https://forum.xojo.com/u/Rob_Lang)\
**Post date:** [July 10, 2015, 9:36am UTC](https://forum.xojo.com/t/popupmenu-in-expanded-position/25408/5 "2015-07-10T09:36:48Z")

</div>

I deploy to OS X and Windowz

Thank you all - great help!

---

<div class="post-metadata">

**Author:** ![DetlefK](https://forum.xojo.com/user_avatar/forum.xojo.com/detlefk/32/23653_2.png) [@DetlefK](https://forum.xojo.com/u/DetlefK)\
**Post date:** [July 10, 2015, 7:41pm UTC](https://forum.xojo.com/t/popupmenu-in-expanded-position/25408/6 "2015-07-10T19:41:30Z")

</div>

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) .

---

<div class="post-metadata">

**Author:** ![Paul\_Lefebvre](https://forum.xojo.com/user_avatar/forum.xojo.com/paul_lefebvre/32/3152_2.png) [@Paul\_Lefebvre](https://forum.xojo.com/u/Paul_Lefebvre)\
**Post date:** [July 10, 2015, 8:59pm UTC](https://forum.xojo.com/t/popupmenu-in-expanded-position/25408/8 "2015-07-10T20:59:43Z")

</div>

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]

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 5:50pm UTC](https://forum.xojo.com/t/popupmenu-in-expanded-position/25408/9 "2020-10-29T17:50:26Z")

</div>


