GUI button is unpressable

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

GUI button is unpressable

Post 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.
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post 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)... ;)
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post 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
      //////////////////////////////
.
.
.
.
Last edited by MasterGod on Wed Sep 26, 2007 10:52 pm, edited 1 time in total.
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

Is there something missing? Do you need anything else so you could help me?
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post 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 ???
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post 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?
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Use the SVN version, it's also working with VC6 :wink:
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

Ok, I'll do that gladly (when I'll get it to work)!
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post 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?
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
TomiZ
Posts: 40
Joined: Wed Aug 29, 2007 6:02 am
Location: Poland
Contact:

Post 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.
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

The problem was the Event Receiver.
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
Post Reply