diff --git a/test/main.c b/test/main.c index f59af288..e519e829 100644 --- a/test/main.c +++ b/test/main.c @@ -20,6 +20,12 @@ int onClosing(uiWindow *w, void *data) return 1; } +int onShouldQuit(void *data) +{ + printf("in onShouldQuit()\n"); + return uiMenuItemChecked(shouldQuitItem); +} + uiBox *mainBox; uiTab *mainTab; @@ -51,6 +57,8 @@ int main(int argc, char *argv[]) if (!nomenus) initMenus(); + uiOnShouldQuit(onShouldQuit, NULL); + w = newWindow("Main Window", 320, 240, 1); uiWindowOnClosing(w, onClosing, NULL); printf("main window %p\n", w); diff --git a/test/menus.c b/test/menus.c index 5a10feaf..5ee264d2 100644 --- a/test/menus.c +++ b/test/menus.c @@ -4,6 +4,7 @@ uiMenu *fileMenu; uiMenuItem *newItem; uiMenuItem *openItem; +uiMenuItem *shouldQuitItem; uiMenuItem *quitItem; uiMenu *editMenu; uiMenuItem *undoItem; @@ -53,6 +54,8 @@ void initMenus(void) fileMenu = uiNewMenu("File"); newItem = uiMenuAppendItem(fileMenu, "New"); openItem = uiMenuAppendItem(fileMenu, "Open"); + uiMenuAppendSeparator(fileMenu); + shouldQuitItem = uiMenuAppendCheckItem(fileMenu, "Should Quit"); quitItem = uiMenuAppendQuitItem(fileMenu); editMenu = uiNewMenu("Edit"); diff --git a/test/test.h b/test/test.h index 8bb01db6..2cacb4ed 100644 --- a/test/test.h +++ b/test/test.h @@ -20,6 +20,7 @@ extern uiBox *newVerticalBox(void); extern uiTab *newTab(void); // menus.c +extern uiMenuItem *shouldQuitItem; extern void initMenus(void); // page1.c