Page 1 of 1

EET_GUI_EVENT and EET_KEY_INPUT_EVENT together?????

Posted: Thu May 06, 2010 2:11 pm
by estamisu
Hi all again...

I solved my previous But now I have a question that can i use EET_GUI_EVENT and EET_KEY_INPUT_EVENT together?
I think that my problem is that I should set two event receivers for them.
I tried but It doesn't .... How ???? do you guys have any idea or advice???

Re: EET_GUI_EVENT and EET_KEY_INPUT_EVENT together?????

Posted: Thu May 06, 2010 2:16 pm
by randomMesh
As far as i know, Irrlicht only sends one event at a time. So one event receiver is sufficient.

Posted: Thu May 06, 2010 3:43 pm
by estamisu
Oh really

So means that I really can not use like this...

Code: Select all

case EET_KEY_INPUT_EVENT:
		
			KeyIsDown[event.KeyInput.Key] = event.KeyInput.PressedDown;
			
			if (IsKeyDown(irr::KEY_KEY_Q))
			{
				exit(0);
			}
			if (IsKeyDown(irr::KEY_SPACE))
			{
				gPause = !gPause;
			}
			if (IsKeyDown(irr::KEY_KEY_W))
			{
				gWireframe = !gWireframe;
			}
			
		break;

		case EET_GUI_EVENT: 
		  
		s32 id = event.GUIEvent.Caller->getID(); 
			
         switch(event.GUIEvent.EventType) 
         { 
            case EGET_CHECKBOX_CHANGED: 
            { 
               IGUICheckBox *cb = (IGUICheckBox *)event.GUIEvent.Caller; 
               switch ( id ) 
               { 
                  case GUI_ID_CHECKBOX_VISIBLE:                     
                     { 
                        button->setVisible( cb->isChecked() ); 
                     } 
                     break; 
                  case GUI_ID_CHECKBOX_ENABLED:                    
                     { 
                        button->setEnabled( cb->isChecked() ); 
                     } 
                     break; 
						   }
			   break;
			
			}
			break;
			default:
				break;
		 }  
		  
      } 

		return false;
	}


	// This is used to check whether a key is being held down
	virtual bool IsKeyDown(EKEY_CODE keyCode) const
	{
		return KeyIsDown[keyCode];
	}
	
	MyEventReceiver()
	{
		for (u32 i=0; i<KEY_KEY_CODES_COUNT; ++i)
		KeyIsDown[i] = false;
	}

	MyEventReceiver(IrrlichtDevice * device, IGUIButton* button)
	{
		device->setEventReceiver(this);
	}



	
				private:
	// We use this array to store the current state of each key
	bool KeyIsDown[KEY_KEY_CODES_COUNT];
But I want to use Is there any way???? 


};

Posted: Fri May 07, 2010 11:11 am
by kingdutch
http://irrlicht.sourceforge.net/docu/example009.html

Look at the event receiver in there, shows how it catches both event types.
I believe that's what you want.

Posted: Sun May 09, 2010 5:01 pm
by estamisu
hi Kingdutch Tnx for the reply It looks like main window is without events... Just screening..
In my case when my game should be stopped when GUI interface appear.

One more things again Can i show button when checkbox is checked...
Is there any idea. I can not find in here...
always thanks for kind replies all