Pressing ESC to close the rendering window ?

Return to C++ coding using Panda3D

Pressing ESC to close the rendering window ?

Postby Juggernaut » Mon Apr 30, 2012 11:43 am

Hello,

In other engines, there is default inbuilt option of hitting the ESC key to close the rendering window and stopping the running application. Is this present in the Panda engine or does it have other different key to do this or do I have to implement it myself in my code ?

Please advice.

Thanks,
Juggernaut
 
Posts: 90
Joined: Sat Feb 11, 2012 5:46 am

Own code.

Postby EdmundosTown » Mon Apr 30, 2012 11:55 am

In PandaFramework:
Code: Select all
void    define_key (const string &event_name, const string &description, EventHandler::EventCallbackFunction *function, void *data);


So, you have to:

Code: Select all
PandaFramework framework;

void exit_event ( const Event *e, void *data )
{
framework->close_all_windows();
}


In your setup section (before looping):
Code: Select all
window->enable_keyboard();
framework.define_key ("escape", "Quit", exit_event, (void *) NULL);


This will halt by-the-hard-way your game, it's recomendable that loop yourself the PandaFramework, so you can stop it when you want.
EdmundosTown
 
Posts: 26
Joined: Mon Oct 17, 2011 1:36 pm
Location: Mexico City, Mexico

Postby Juggernaut » Mon Apr 30, 2012 11:59 am

@EdmundosTown: Thanks a lot for helping me out ..... :)

I will look into it ..... thanks.
Juggernaut
 
Posts: 90
Joined: Sat Feb 11, 2012 5:46 am


Return to C++ coding using Panda3D

Who is online

Users browsing this forum: Yahoo [Bot] and 0 guests