| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] | 
To make the testing somewhat easier we will add a way to terminate the application by responding to the ESC key. Add the following private method to our class in `simple.h':
| bool OnKeyboard (iEvent&); | 
The function OnKeyboard() will be called when an event arrives
Add the following code to `simple.cpp' just before
Simple::OnInitialize():
| bool Simple::OnKeyboard(iEvent& ev)
{
  csKeyEventType eventtype = csKeyEventHelper::GetEventType(&ev);
  if (eventtype == csKeyEventTypeDown)
  {
    utf32_char code = csKeyEventHelper::GetCookedCode(&ev);
    if (code == CSKEY_ESC)
    {
      csRef<iEventQueue> q =
        csQueryRegistry<iEventQueue> (GetObjectRegistry());
      if (q.IsValid()) q->GetEventOutlet()->Broadcast(csevQuit (
      	GetObjectRegistry ()));
    }
  }
  return false;
}
 | 
OnKeyboard() checks if the ESC key has been pressed. If so it
uses the object registry to find the global event queue object. Using
Broadcast() it then broadcasts the `csevQuit' message
to all interested parties. This will cause the application to quit by
terminating the run-loop.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | 
 
  This document was generated using texi2html 1.76.