WideStudio/MWT Logo
Programming Guide
WideStudio/MWT Index
Table of contents

How to use the global key hook function

You can use the global key hook to check the keyboard event before dispatching, by adding a hook procedure to the keyboard instance.

The keyboard class Access function
WSDkeyboard WSGIappKeyboard()

#include <WSDkeyboard.h>
//A sample of the global key hook
WSCbool keyhandler(long keycode,Boolean onoff){
  // keycode : the key code (see WSkeysym.h)
  // onoff   : True = keypress, False= key release.
  if (keycode == WSK_F1){
    //The key code is  F1...
    //if discard this...
    return False; //return the False: discard.
  }else if (keycode == WSK_F2){
    //The key code is  F2...
    //if dispatch this...
    return True; //return the True: dispatch.
  return True; //return the True: dispatch.
void event_procedure(WSCbase* obj){
  //the registration of the global key hook procedure.
  WSGIappKeyboard()->setGlobalKeyHook( keyhandler );

keyhandler() is the procedure which grabs the key board events to do something specially. You can register it with WSGIappKeyboard()->setGlobalKeyHook(),

See the header file: WSkeysym.h if you want the key codes.

Document Release 3.90 for WideStudio/MWT ver 3.90, Jul 2005

WideStudio/MWT documents index | Table of contents

Copyright(C) WideStudio/MWT Development Team, 1999-2005 Last modified: Jul 31, 2005