al_insert_menu_item(3alleg5)

πŸ“¦
version 5.2.11.3 Β· 5 versions
, in ubuntu resolute, ubuntu stonking

πŸ’– 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_CHECKBOX will 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