Files
kryon/examples/10_menus.kry
T
2026-08-09 19:52:01 -03:00

26 lines
995 B
Plaintext

#import "kryon.h"
app "Kryon Menus" {
size 800 600
fps 60
font examples
theme THEME_SKY light
}
state {
open_menu: int = -1
status: [64] char = "No menu command"
}
screen MenusExample(viewport: Rectangle) {
Background(GetThemeBackground())
file_items: [4] UIMenuItem = {{UI_MENU_COMMAND,"New","Ctrl+N",1,0,0,NULL,0},{UI_MENU_COMMAND,"Open","Ctrl+O",2,0,0,NULL,0},{UI_MENU_SEPARATOR,NULL,NULL,0,0,0,NULL,0},{UI_MENU_COMMAND,"Quit","Esc",3,0,0,NULL,0}}
view_items: [3] UIMenuItem = {{UI_MENU_CHECK,"Show Grid","G",4,0,1,NULL,0},{UI_MENU_RADIO,"Compact",NULL,5,0,0,NULL,0},{UI_MENU_RADIO,"Comfortable",NULL,6,0,1,NULL,0}}
menus: [2] UIMenu = {{{0},"File",file_items,4},{{0},"View",view_items,3}}
result: UIMenuBarResult = MenuBar(100,(Rectangle){0,0,GetScreenWidth(),34},menus,2,&open_menu)
if result.activated_id != 0 {
snprintf(status,sizeof(status),"Command %d",result.activated_id)
}
Text(status, 40, 80, 20, GetThemeText())
}