Irrlict o.12 events problems.

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
[SOM]Roberto.

Irrlict o.12 events problems.

Post by [SOM]Roberto. »

What's the problem in my code :?:

bool CMainMenu::OnEvent(irr::SEvent event) {
using namespace irr;
using namespace gui;

if (event.EventType == EET_GUI_EVENT) {

s32 id = event.GUIEvent.Caller->getID();

switch(event.GUIEvent.EventType) {

case EGET_BUTTON_CLICKED:
if(id == 2) {
printf("it's an event");
return true;
}
break;
}
}
return false;
}

This is the techdemo real code is bad too:

bool CMainMenu::OnEvent(irr::SEvent event)
{
if (event.EventType == EET_GUI_EVENT)
{
s32 id = event.GUIEvent.Caller->getID();
switch(id)
{
case 2:
if (event.GUIEvent.EventType == gui::EGET_BUTTON_CLICKED )
{
device->closeDevice();
start = true;
}
break;
}
}
return false;
}

The tutorial 5 events is perfetcly. What is the problem :?: How do i implemet the events in classes with irrlict o.12 perfetcly :?:
Midnight
Posts: 1772
Joined: Fri Jul 02, 2004 2:37 pm
Location: Wonderland

Post by Midnight »

uhh... What?
luckymutt
Posts: 453
Joined: Sun Mar 06, 2005 11:56 pm
Location: C-Ville

Post by luckymutt »

for starters, why are you putting

Code: Select all

using namespace irr; 
using namespace gui;
within your bool CMainMenu::OnEvent(irr::SEvent event) {
?
[SOM]Roberto.

Post by [SOM]Roberto. »

luckymutt wrote:for starters, why are you putting

Code: Select all

using namespace irr; 
using namespace gui;
within your bool CMainMenu::OnEvent(irr::SEvent event) {
?
Yes, Yes. No problem! I implemented my game the events in classes:

class Start : public IEventReceiver
{
public:
virtual bool OnEvent(SEvent event);
......

Start Start_event;

device = createDevice(video::EDT_SOFTWARE, core::dimension2d<s32>(512, 384), 16, false, false, false, &Start_event);
.......

bool Start::OnEvent(SEvent event)

:P :P
[SOM]Roberto.

Post by [SOM]Roberto. »

Thak you the perious helpig.

Next problem. How can I witch the Message Box button events :?:

//=======================================================================
bool Start::OnEvent(SEvent event)
{
if (event.EventType == EET_GUI_EVENT)
{
s32 id = event.GUIEvent.Caller->getID();

switch(event.GUIEvent.EventType)
{
case gui::EGET_BUTTON_CLICKED: //button click events
if (id == 2) //exit button
{
device->getGUIEnvironment()->addMessageBox(Caption.c_str(), MessageText.c_str(), true, (EMBF_OK | EMBF_NO), 0, 101);
}
else
if (id == 101) //message box OK button
{
device->closeDevice();
return true;
}
break;

Why don't do anything on message box OK button?
[SOM]Roberto.

Post by [SOM]Roberto. »

Well: How can I witch the Message Box button events :?: :P
[SOM]Roberto.

Post by [SOM]Roberto. »

:cry: :cry: :cry:
Kosomot
Posts: 5
Joined: Sun Apr 17, 2005 12:26 pm
Location: Poland
Contact:

Post by Kosomot »

You need to catch EGET_MESSAGEBOX_OK instead of EGET_BUTTON_CLICKED.
[SOM]Roberto.

Post by [SOM]Roberto. »

Kosomot wrote:You need to catch EGET_MESSAGEBOX_OK instead of EGET_BUTTON_CLICKED.
Thank yuo very much. Thats OK!! :P :P
Post Reply