Added more menu item enabled/disabled checks. This is important because on OS X we have to hook into the delegat eot disable the three special items (we can't just set autoenable to false; the Hide/Show items won't be properly disabled anymore if we do).
This commit is contained in:
parent
c89b473c76
commit
a0e2c3cf94
29
test/menus.c
29
test/menus.c
|
@ -15,16 +15,21 @@ uiMenuItem *enabledItem;
|
|||
uiMenuItem *enableThisItem;
|
||||
uiMenuItem *forceCheckedItem;
|
||||
uiMenuItem *forceUncheckedItem;
|
||||
uiMenu *moreTestsMenu;
|
||||
uiMenuItem *quitEnabledItem;
|
||||
uiMenuItem *prefsEnabledItem;
|
||||
uiMenuItem *aboutEnabledItem;
|
||||
uiMenuItem *checkEnabledItem;
|
||||
uiMenu *helpMenu;
|
||||
uiMenuItem *helpItem;
|
||||
uiMenuItem *aboutItem;
|
||||
|
||||
static void enableItemTest(uiMenuItem *item, uiWindow *w, void *data)
|
||||
{
|
||||
if (uiMenuItemChecked(enabledItem))
|
||||
uiMenuItemEnable(enableThisItem);
|
||||
if (uiMenuItemChecked(item))
|
||||
uiMenuItemEnable(uiMenuItem(data));
|
||||
else
|
||||
uiMenuItemDisable(enableThisItem);
|
||||
uiMenuItemDisable(uiMenuItem(data));
|
||||
}
|
||||
|
||||
static void forceOn(uiMenuItem *item, uiWindow *w, void *data)
|
||||
|
@ -55,14 +60,30 @@ void initMenus(void)
|
|||
testMenu = uiNewMenu("Test");
|
||||
enabledItem = uiMenuAppendCheckItem(testMenu, "Enable Below Item");
|
||||
uiMenuItemSetChecked(enabledItem, 1);
|
||||
uiMenuItemOnClicked(enabledItem, enableItemTest, NULL);
|
||||
enableThisItem = uiMenuAppendItem(testMenu, "This Will Be Enabled");
|
||||
uiMenuItemOnClicked(enabledItem, enableItemTest, enableThisItem);
|
||||
forceCheckedItem = uiMenuAppendItem(testMenu, "Force Above Checked");
|
||||
uiMenuItemOnClicked(forceCheckedItem, forceOn, NULL);
|
||||
forceUncheckedItem = uiMenuAppendItem(testMenu, "Force Above Unchecked");
|
||||
uiMenuItemOnClicked(forceUncheckedItem, forceOff, NULL);
|
||||
|
||||
moreTestsMenu = uiNewMenu("More Tests");
|
||||
quitEnabledItem = uiMenuAppendCheckItem(moreTestsMenu, "Quit Item Enabled");
|
||||
uiMenuItemSetChecked(quitEnabledItem, 1);
|
||||
prefsEnabledItem = uiMenuAppendCheckItem(moreTestsMenu, "Preferences Item Enabled");
|
||||
uiMenuItemSetChecked(prefsEnabledItem, 1);
|
||||
aboutEnabledItem = uiMenuAppendCheckItem(moreTestsMenu, "About Item Enabled");
|
||||
uiMenuItemSetChecked(aboutEnabledItem, 1);
|
||||
uiMenuAppendSeparator(moreTestsMenu);
|
||||
checkEnabledItem = uiMenuAppendCheckItem(moreTestsMenu, "Check Me Item Enabled");
|
||||
uiMenuItemSetChecked(checkEnabledItem, 1);
|
||||
|
||||
helpMenu = uiNewMenu("Help");
|
||||
helpItem = uiMenuAppendItem(helpMenu, "Help");
|
||||
aboutItem = uiMenuAppendAboutItem(helpMenu);
|
||||
|
||||
uiMenuItemOnClicked(quitEnabledItem, enableItemTest, quitItem);
|
||||
uiMenuItemOnClicked(prefsEnabledItem, enableItemTest, prefsItem);
|
||||
uiMenuItemOnClicked(aboutEnabledItem, enableItemTest, aboutItem);
|
||||
uiMenuItemOnClicked(checkEnabledItem, enableItemTest, checkItem);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue