Key Press for Quit, How To?
-
firefly2442
- Posts: 38
- Joined: Mon May 31, 2004 7:55 am
- Contact:
Key Press for Quit, How To?
I'm going through the tutorials and I was wondering how I could get the key press of 'Esc' or 'Q' in order to quit the demo. Is there some forcequit way? I've been giving the examples the old "three finger salute" with CTRL-ALT-DELETE. Thanks. 
-
Peter Müller
- Posts: 292
- Joined: Sun Mar 14, 2004 5:28 pm
- Location: Germany
- Contact:
Don't think so. But why don't you just use the KEY_INPUT event of the EventReceiver (max. 10 lines of code)?I think there must be a way to assign the quit function straight to a key
http://www.games-forge.de - Die Community für Nachwuchsprogrammierer
-
Asterisk Man
simple way (with a global var tho)
here's what I use for a few progs:
bool exit = false;
class MyEventReceiver: public IEventReceiver
{
virtual bool OnEvent(SEvent event)
{
switch(event.KeyInput)
{
case KEY_ESCAPE:
exit = true;
}
}
}
.
.
.
int main()
{
while(device->run() && exit == false)
{
.
.
.
}
}
fill the ...s with whatever you like, but I hope you see what i'm doing. if you already use and EventReceiver class, this should be a 5-6 line addition to your code.
Hope it helps!
bool exit = false;
class MyEventReceiver: public IEventReceiver
{
virtual bool OnEvent(SEvent event)
{
switch(event.KeyInput)
{
case KEY_ESCAPE:
exit = true;
}
}
}
.
.
.
int main()
{
while(device->run() && exit == false)
{
.
.
.
}
}
fill the ...s with whatever you like, but I hope you see what i'm doing. if you already use and EventReceiver class, this should be a 5-6 line addition to your code.
Hope it helps!
-
Peter Müller
- Posts: 292
- Joined: Sun Mar 14, 2004 5:28 pm
- Location: Germany
- Contact:
