Implemented the Quit menu item shouldQuit() logic on Windows.

This commit is contained in:
Pietro Gagliardi 2015-05-09 10:53:38 -04:00
parent 5ef355f28f
commit 5e258c0c48
1 changed files with 10 additions and 0 deletions

View File

@ -68,6 +68,12 @@ static void defaultOnClicked(uiMenuItem *item, uiWindow *w, void *data)
// do nothing
}
static void onQuitClicked(uiMenuItem *item, uiWindow *w, void *data)
{
if (shouldQuit())
uiQuit();
}
static void menuItemEnable(uiMenuItem *ii)
{
struct menuItem *item = (struct menuItem *) ii;
@ -88,6 +94,8 @@ static void menuItemOnClicked(uiMenuItem *ii, void (*f)(uiMenuItem *, uiWindow *
{
struct menuItem *item = (struct menuItem *) ii;
if (item->type == typeQuit)
complain("attempt to call uiMenuItemOnClicked() on a Quit item; use uiOnShouldQuit() instead");
item->onClicked = f;
item->onClickedData = data;
}
@ -150,6 +158,8 @@ static uiMenuItem *newItem(struct menu *m, int type, const char *name)
}
item->onClicked = defaultOnClicked;
if (item->type == typeQuit)
item->onClicked = onQuitClicked;
uiMenuItem(item)->Enable = menuItemEnable;
uiMenuItem(item)->Disable = menuItemDisable;