Page 1 of 1

GUI button is unpressable

Posted: Tue Sep 25, 2007 4:19 pm
by MasterGod
I have created a button just like in the tutorials and I when I press on it nothing happens, I mean it doesn't look like the button is being pressed instead it looks like it ignore my clicks.

Posted: Tue Sep 25, 2007 6:09 pm
by Acki
shall we guess or do you think we are mental magicians ?!?!? :roll:
provide some code !!!
in your case it's probably the event receiver (also just guessing)... ;)

Posted: Tue Sep 25, 2007 7:24 pm
by MasterGod
I use MastEventReceiver.

Code: Select all

struct SDevice
{
	IrrlichtDevice	*device;	
	IVideoDriver	*driver;
	ISceneManager	*smgr;
	IGUIEnvironment *gui;
	ISoundEngine	*sound_Engine;
	MastEventReceiver *eventReceiver;
};

// for the places you see DeviceInfo..
SDevice DeviceInfo;
In Main:

Code: Select all

CGUI *GUI = new CGUI(GS->getSDevice());
while(device->run() && driver)
	if (device->isWindowActive())
	{
		driver->beginScene(true, true, SColor(255,0,0,0));
	
		eventReceiver->endEventProcess(); 

		switch (OrderOfThings)
		{
		case E_INTRO:
			if (Intro)
				if (Intro->drawAll())
				{
					delete Intro; Intro = 0;
					OrderOfThings = E_MENU;
				}
			break;

		case E_MENU:
			device->getCursorControl()->setVisible(true);
			device->getCursorControl()->setPosition(device->getCursorControl()->getPosition());
			GUI->setVisible(GUI_MENU, true);
			//OrderOfThings = E_GAME;
			break;

		case E_GAME:
			GUI->setVisible(GUI_MENU, false);
			GUI->setVisible(GUI_GAME, true);
			OrderOfThings = E_EXIT;
			break;

		case E_EXIT:
			device->closeDevice();
			break;
		}

		if (eventReceiver->keyPressed(27))
			device->closeDevice();
		
		GUI->drawAll();

		eventReceiver->startEventProcess();

		driver->endScene();
	}
In CGUI:

Code: Select all

void CGUI::setVisible(E_GUIS gui, bool flag)
{
	switch (gui)
	{
	case GUI_MENU:
		Buttons[0]->setVisible(flag);
		break;
	case GUI_GAME:
		break;
	}
}

void CGUI::drawAll()
{
	s32 fps = DeviceInfo.driver->getFPS();
	stringw stFPS = "FPS: "; stFPS += fps;

	if ((font) && (font_Big))
		font_Big->draw(stFPS.c_str(), rect<s32>(0,0,20,10), SColor(255,255,255,128));

	DeviceInfo.gui->drawAll();
}

void CGUI::Load_Menu() // called in the constructor
{
	IGUIButton *button = 0;

	button = DeviceInfo.gui->addButton(rect<s32>(350,250,400,300), 0, 101, L"Quit", L"Exits Program");
	button->setVisible(false);
	Buttons.push_back(button);
}
in MastEventReceiver.hpp (I added to the original)

Code: Select all

 virtual bool OnEvent(const SEvent& event)
   {
	  bool eventprocessed = false;

	  //////////////////////////////
      // GUI Input Event
      //////////////////////////////
      if (event.EventType == EET_GUI_EVENT)
      {
		  s32 id = event.GUIEvent.Caller->getID();

		  switch(event.GUIEvent.EventType)
		  {
		  case EGET_BUTTON_CLICKED:
			  if (id == 101)
			  {
				  device->closeDevice();
				  return true;
			  }
			  break;
		  default:
			  break;
		  }
      }

      //////////////////////////////
      // Keyboard Input Event
      //////////////////////////////
.
.
.
.

Posted: Wed Sep 26, 2007 5:25 pm
by MasterGod
Is there something missing? Do you need anything else so you could help me?

Posted: Wed Sep 26, 2007 6:35 pm
by Acki
the receiver (at least the part you posted) seems to be correct...
Although I don't know anything about this MastEventReceiver... ;)

Did you pass the receiver correctly to the device ???
Is it correct to call eventReceiver->startEventProcess(); before driver->endScene(); ???
Was there not a focus problem (bug) in v1.3.1, maybe this is you problem ???

Posted: Wed Sep 26, 2007 9:43 pm
by MasterGod
Acki wrote: Was there not a focus problem (bug) in v1.3.1, maybe this is you problem ???
I'v just read about this problem, I think this is it, cause the receiver is working fine, exactly as it should but it looks like I cant interact with the button at all so maybe its the focus thing..
So what can I do if it is that problem?

Posted: Wed Sep 26, 2007 9:47 pm
by hybrid
Use the SVN version, it's also working with VC6 :wink:

Posted: Wed Sep 26, 2007 9:58 pm
by MasterGod
Ok, I'll do that gladly (when I'll get it to work)!

Posted: Thu Sep 27, 2007 6:30 am
by MasterGod
SVN works but I still has that problem, I guess its has to do with the code itself. So looking few posts back, is there something wrong with the code?

Posted: Thu Sep 27, 2007 6:47 am
by TomiZ
Maybe you have invisible object above the button. For example in addStaticText you have used too big rectangle to make sure that it will be big enough to text.

Posted: Thu Oct 04, 2007 2:02 pm
by MasterGod
The problem was the Event Receiver.