al_popup_menu(3alleg5)
π al_popup_menu β Allegro 5 API π
okay bestie, sit down, hydrate, and let's talk about popping up a lil menu right next to your cursor β¨ This one lives in the Allegro 5 API (section 3alleg5 if you're keeping score), and it's giving right-click energy in the best way.
β¨ SYNOPSIS β¨
#include <allegro5/allegro_native_dialog.h>
bool al_popup_menu(ALLEGRO_MENU *popup, ALLEGRO_DISPLAY *display)
πΈ DESCRIPTION πΈ
So the way that this works is: it displays a context menu next to the mouse cursor. That's it. That's the whole vibe. π±οΈβ¨
Heads up though β the menu has to have been created with al_create_popup_menu(3alleg5) first. You can't just roll up with any old menu, she needs to be born a popup menu, iykyk.
Once it's up, it generates events just like a regular display menu does β same event flow, same energy, no special treatment. π
And lowkey important: it is possible that the menu will be canceled without any selection being made. Like, user clicks away, hits escape, changes their mind β no selection, no problem, that's a valid outcome fr fr.
Now, the display parameter β this one trips people up so listen closely π«Ά. It indicates which window the menu is associated with (specifically when you process the menu click event). But β and this is the part everyone gets wrong β it does not actually affect where the menu is located on the screen. It's an association thing, not a positioning thing. The menu goes where the cursor is, periodt. π
Returns true if the context menu was displayed.
β οΈ Linux besties, this one's for you: on Linux this function will fail if any of the mouse keys are held down. I.e. it will only reliably work if you handle it in ALLEGRO_MOUSE_BUTTON_UP events β and even then, only if that event corresponds to the final mouse button that was pressed. Not me finding this out the hard way π Handle your button-up events properly, okay?
π SINCE π
5.1.0 β she's been iconic since day one, no cap. π
π¦ SEE ALSO π¦
al_create_popup_menu(3alleg5)β go make your menu first, bestie, you can't skip this step π
and that's the whole page!! this came to you straight from the Allegro reference manual, al_popup_menu(3alleg5), section 3alleg5 β go forth and pop up some menus, you absolute main character πβ¨π
π¦ where this page comes from
- debian trixie: allegro5-doc 2:5.2.10.1+dfsg-1 Β· Zlib
- ubuntu questing: allegro5-doc 2:5.2.10.1+dfsg-1build1
- ubuntu resolute: allegro5-doc 2:5.2.11.3+dfsg-1 Β· Zlib
- ubuntu stonking: allegro5-doc 2:5.2.11.3+dfsg-1 Β· Zlib
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms