Page 1 of 1

Click on an image

Posted: Thu Jun 22, 2006 9:56 pm
by sivagiri
How could I click on an image, then when I do it it shows a message....?

Posted: Thu Jun 22, 2006 10:08 pm
by sudi
Dude just read the ****** tutorials!!!!!!
I typed a special one just for u cause i was bored....but read the tutorial

IrrlichtDevice* device;
video::IVideoDriver* driver;
gui::IGUIEnvironment* gui;
IGUIButton button;

class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(SEvent event)
{
if (event.EventType == EET_GUI_EVENT)
{
s32 id = event.GUIEvent.Caller->getID();
IGUIEnvironment* env = device->getGUIEnvironment();

switch(event.GUIEvent.EventType)
{
case EGET_BUTTON_CLICKED:
if (id == 200)
{
gui->addWindow(rect<s32>(10,10,90,90),false,L"HALLO");
return true;
}
break;
}
return false;
}
};

int main()
{
device = createDevice(video::EDT_OPENGL, core::dimension2d<s32>(640,480), 16 , false, false, false, new MyEventReceiver());

driver = device->getVideoDriver();
gui = device->getGUIEnvironment() ;

button = gui->addButton(rect<s32>(50,50,100,100),0,200);
button->setImage(driver->getTexture("YOUR TEXTURE") ;


// draw everything
while(device->run() && driver)
{
driver->beginScene(true, true, video::SColor(255,0,0,255));
gui->drawAll();
driver->endScene();
}

// delete device
device->drop();


}

Posted: Thu Jun 22, 2006 10:48 pm
by sivagiri
thanx :lol:

Posted: Thu Jun 22, 2006 11:27 pm
by sivagiri
I'm a bit tired: thats the prob and having cold.

One more question or two:


I would like the image on my button fit the button totally: How can I do that?

:)

Posted: Thu Jun 22, 2006 11:44 pm
by sivagiri
button1 = env->addButton(rect<s32>(120,160,270,350),0,200);
button1->setImage(driver->getTexture("mediam/pics/kep1.bmp"),core::rect< s32>(120,160,270,350));


I did this, and it fits the button, but looks kind of :oops: ....

Posted: Wed Jul 05, 2006 7:55 am
by RhavoX
button1->setImage(driver->getTexture("mediam/pics/kep1.bmp"rect<s32>(120,160,270,350));

Code: Select all

rect<s32>(120,160,270,350));
This sets the position of an image IN your button, not in the program window..The fisrt two coordinates should be set to 0, the other two to the image's width and height. :)
But this part is not even necessary. If your image's width and height are powers of 2, then it will be displayed correctly and it will fit the button :)