1
// Copyright (C) 2008-2011 Colin MacDonald
2
// No rights reserved: this software is in the public domain.
10
// Tests that disabled GUI menu items don't cause their submenu to appear when hovered over.
12
http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?p=178436#178436
15
bool guiDisabledMenu(void)
17
IrrlichtDevice *device = createDevice( video::EDT_BURNINGSVIDEO,
18
dimension2d<u32>(160, 40), 32);
23
video::IVideoDriver* driver = device->getVideoDriver();
24
gui::IGUIEnvironment* env = device->getGUIEnvironment();
26
gui::IGUIContextMenu* menu = env->addMenu();
27
menu->addItem(L"Menu", -1, true, true);
28
gui::IGUIContextMenu* subMenu = menu->getSubMenu(0);
29
subMenu->addItem(L"Submenu 1", -1, false, true);
30
gui::IGUIContextMenu* subSubMenu = subMenu->getSubMenu(0);
31
subSubMenu->addItem(L"Final item");
34
event.EventType = EET_MOUSE_INPUT_EVENT;
35
event.MouseInput.Event = EMIE_LMOUSE_PRESSED_DOWN;
36
event.MouseInput.X = menu->getAbsolutePosition().UpperLeftCorner.X + 1;
37
event.MouseInput.Y = menu->getAbsolutePosition().UpperLeftCorner.Y + 1;
38
(void)menu->OnEvent(event);
40
// Hovering over the disabled submenu shouldn't cause the "Final item" to appear.
41
event.MouseInput.Event = EMIE_MOUSE_MOVED;
42
event.MouseInput.X = subMenu->getAbsolutePosition().UpperLeftCorner.X + 40;
43
event.MouseInput.Y = subMenu->getAbsolutePosition().UpperLeftCorner.Y + 10;
44
(void)menu->OnEvent(event);
47
driver->beginScene(true, true, video::SColor(150,50,50,50));
51
bool result = takeScreenshotAndCompareAgainstReference(driver, "-guiDisabledMenu.png", 98.77f);
52
device->closeDevice();