Added a test for uiOnShouldQuit().

This commit is contained in:
Pietro Gagliardi 2015-05-09 10:12:02 -04:00
parent 8032c24f74
commit 4e9fa46aec
3 changed files with 12 additions and 0 deletions

View File

@ -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);

View File

@ -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");

View File

@ -20,6 +20,7 @@ extern uiBox *newVerticalBox(void);
extern uiTab *newTab(void);
// menus.c
extern uiMenuItem *shouldQuitItem;
extern void initMenus(void);
// page1.c