Is there a way to open a pop-up menu by program?

Hello togehter,

is there someone who knows how i can open a popup menu from a function or open event?
I would like to get the user to make a selection in the popup list first, after opening a window.

Thanks a lot

Ralf

you can create a menuitem with the same content as your popupmenu (with the List property of the popupmenu)
then call the popup method of that menuitem after opening your window.

Here’s a little demo project for windows.

https://www.dropbox.com/s/3ejysqtjpmdlocd/OpenPopupWithCode.xojo_binary_project?dl=1

Maybe someone can post a mac/linux example too?

For future searches, here’s the code:

Const CB_SHOWDROPDOWN = &h14f Const WM_SETCURSOR = &h20 Declare Function SendMessage Lib "User32" Alias "SendMessageW" (hWnd As Integer, Msg As UInt32, wParam As UInteger, lParam As Integer) As Integer Call SendMessage(PopupMenu1.Handle, CB_SHOWDROPDOWN, 1, 0) 'open the drop down Call SendMessage(Window1.Handle, WM_SETCURSOR, 0, 0) 'fix the cursor

Redesign your UI?
It doesn’t make sense ->having<- to make a choice in a PopupMenu, if the choice gets hidden (e.g. by accident with a mouse-click outside; by losing the focus if application gets in background, …).
Why not show a ListBox with the choices (on PagePanel Index 0), and once a selection has made: [continue] (to PagePanel Index 1)?

Thank you all together…

This idea has also just come to me…

[quote=371998:@]Here’s a little demo project for windows.

https://www.dropbox.com/s/3ejysqtjpmdlocd/OpenPopupWithCode.xojo_binary_project?dl=1

Maybe someone can post a mac/linux example too?

For future searches, here’s the code:

Const CB_SHOWDROPDOWN = &h14f Const WM_SETCURSOR = &h20 Declare Function SendMessage Lib "User32" Alias "SendMessageW" (hWnd As Integer, Msg As UInt32, wParam As UInteger, lParam As Integer) As Integer Call SendMessage(PopupMenu1.Handle, CB_SHOWDROPDOWN, 1, 0) 'open the drop down Call SendMessage(Window1.Handle, WM_SETCURSOR, 0, 0) 'fix the cursor[/quote]

Nice one! What’s the solution for MacOS?