al_insert_menu_item(3alleg5)
π al_insert_menu_item β Allegro 5 API π
okay bestie, we're in the allegro5 manual and today's main character is al_insert_menu_item. it does exactly what it says on the tin: it slides a menu item into a menu at the exact spot you want. sooo satisfying. β¨
β¨ SYNOPSIS β¨
#include <allegro5/allegro_native_dialog.h>
int al_insert_menu_item(ALLEGRO_MENU *parent, int pos, char const *title,
uint16_t id, int flags, ALLEGRO_BITMAP *icon, ALLEGRO_MENU *submenu)
πΈ DESCRIPTION πΈ
so you wanna insert a menu item at the spot specified. slay. and if you're like "girl what does pos even mean" β no worries, the introductory text has a whole detailed explanation of how the pos parameter is interpreted. go read it, i'll wait. π
the parent menu can be a popup menu or a regular menu, both are valid, we don't discriminate here. π«Ά
and here's a cute lil trick: to underline one character in the title, just prefix it with an ampersand (&). iconic behavior honestly.
π the flags π
the flags can be any combination of these:
ALLEGRO_MENU_ITEM_DISABLEDβ the item is "grayed out" and cannot be selected. it's giving β¨unbotheredβ¨ but also kinda sad ngl.ALLEGRO_MENU_ITEM_CHECKBOXβ the item is a check box. > this flag can only be set at the time the menu is created β no takebacks. and if a check box gets clicked, it will automatically be toggled. it just does that. πALLEGRO_MENU_ITEM_CHECKEDβ the item is checked. and listen: if you set this one,ALLEGRO_MENU_ITEM_CHECKBOXwill automatically be set as well. they're a package deal fr fr.
π¦ a couple more things π¦
the icon is not yet supported. so don't come for me, it's just not a thing yet. π
the submenu parameter is how you say "hey, this item contains a child menu." π that child menu must have previously been created with al_create_menu, and it must not be associated with any other menu. one menu, one parent, we're monogamous here. π
π what you get back π
it returns the index at which the item was inserted β which can be different than what is implied by pos, so don't be shocked β or -1 if there was an error. π
β SINCE β
5.1.0 β a classic, we stan.
π§ SEE ALSO π§
okay that's the whole page, go forth and build menus bestie πΈπβ¨
Allegro reference manual β al_insert_menu_item(3alleg5) π mwah, love u, bye π«Ά
π¦ where this page comes from
- 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