Page 1 of 1

[fixed]Modal + checkbox, click checkbox, window blinks

Posted: Thu Dec 16, 2010 11:08 am
by yaten
I have encountered something weird, I'm not sure if this is a bug, but would like to ask others for opinion.

This is how it goes:
I created a window of type Modal, then placed a checkbox on it. If you click the checkbox, the whole window blinks, as if you are being reminded that you have a modal window still open so you cannot click other places except the Modal window. But the checkbox is at the Modal window, so in my opinion it should NOT be blinking, unless I didn't understand that right ^_^

Take the example program "05.UserInterface"

at the part:

Code: Select all

IGUIWindow* window = env->addWindow(
rect<s32>(100 + Context.counter, 100 + Context.counter, 300 + Context.counter, 200 + Context.counter),
false, // modal?
L"Test window");
just make it 'true' to make the window Modal.

Then simply add a checkbox:

Code: Select all

bool sw = false;
env->addCheckBox(sw, core::rect<int>(35,10,140,50),
window, 1, L"Sample Checkbox");

or simply copy and paste this slightly condensed version of the UserInterface sample program:

Code: Select all

#include <irrlicht.h>
#include "driverChoice.h"
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
#ifdef _IRR_WINDOWS_
#pragma comment(lib, "Irrlicht.lib")
#endif
struct SAppContext
{
	IrrlichtDevice *device;
	s32				counter;
	IGUIListBox*	listbox;
};
enum
{
	GUI_ID_QUIT_BUTTON = 101,
	GUI_ID_NEW_WINDOW_BUTTON,
	GUI_ID_FILE_OPEN_BUTTON,
	GUI_ID_TRANSPARENCY_SCROLL_BAR
};
class MyEventReceiver : public IEventReceiver
{
public:
	MyEventReceiver(SAppContext & context) : Context(context) { }
	virtual bool OnEvent(const SEvent& event)
	{
		if (event.EventType == EET_GUI_EVENT)
		{
			s32 id = event.GUIEvent.Caller->getID();
			IGUIEnvironment* env = Context.device->getGUIEnvironment();
			switch(event.GUIEvent.EventType)
			{
			case EGET_BUTTON_CLICKED:
				switch(id)
				{
				case GUI_ID_NEW_WINDOW_BUTTON:
					{
					Context.listbox->addItem(L"Window created");
					Context.counter += 30;
					if (Context.counter > 200)
						Context.counter = 0;
					IGUIWindow* window = env->addWindow(
						rect<s32>(100 + Context.counter, 100 + Context.counter, 300 + Context.counter, 200 + Context.counter),
						true, // modal?
						L"Test window");
					bool sw = false;
					env->addCheckBox(sw, core::rect<int>(35,10,140,50),
					window, 1, L"Sample Checkbox");
					}
					return true;
				default:
					return false;
				}
				break;
			default:
				break;
			}
		}
		return false;
	}
private:
	SAppContext & Context;
};

int main()
{
	video::E_DRIVER_TYPE driverType=driverChoiceConsole();
	if (driverType==video::EDT_COUNT)
		return 1;
	IrrlichtDevice * device = createDevice(driverType, core::dimension2d<u32>(640, 480));
	if (device == 0) return 1;
	device->setWindowCaption(L"Irrlicht Engine - User Interface Demo");
	device->setResizable(true);
	video::IVideoDriver* driver = device->getVideoDriver();
	IGUIEnvironment* env = device->getGUIEnvironment();
	IGUISkin* skin = env->getSkin();
	IGUIFont* font = env->getFont("../../media/fonthaettenschweiler.bmp");
	if (font)
		skin->setFont(font);
	env->addButton(rect<s32>(10,280,110,280 + 32), 0, GUI_ID_NEW_WINDOW_BUTTON,
			L"New Window", L"Launches a new Window");
	IGUIListBox * listbox = env->addListBox(rect<s32>(50, 140, 250, 210));
	SAppContext context;
	context.device = device;
	context.counter = 0;
	context.listbox = listbox;
	MyEventReceiver receiver(context);
	device->setEventReceiver(&receiver);
	while(device->run() && driver)
	if (device->isWindowActive())
	{
		driver->beginScene(true, true, SColor(0,200,200,200));
		env->drawAll();
		driver->endScene();
	}
	device->drop();
	return 0;
}
run the program, click new window, the window will appear, a modal type window, click the checkbox and see the window blinking. Is that a bug? Its not really a big deal, I could live with that ^_^ I just want to make sure the the cause of it isn't because of my ignorance. ^_^

Posted: Thu Dec 16, 2010 12:32 pm
by CuteAlien
Thanks, that sounds like a bug.

Posted: Thu Dec 16, 2010 8:31 pm
by yaten
CuteAlien wrote:Thanks, that sounds like a bug.
No problem sir, I'm glad it helped even if just a little. I'd really like to contribute something to this great project, but I'm not an expert. So I could only try to report bugs and evangelize the use of this Engine. ^_^

Posted: Fri Dec 17, 2010 12:16 am
by CuteAlien
Fixed it in svn release branch 1.7, svn trunk will follow soon as usual.

I also changed that modalscreens now prefer giving focus to their first child instead of taking it themself as that lead to dialogs losing the focus all the time.

Thanks also for the nice testcase :-)

Posted: Fri Dec 17, 2010 6:19 pm
by yaten
Wow that was fast! Thanks sir ^_^