Wide Studio Programmer's Guide

Wide Studio Home
Up to


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 1.3

For Use with Wide Studio Release 1.3, Summer 2001


Wide Stuido Home | Up to

Copyright(C) T. Hirabayashi, 2000-2001 Last modified: August 20, 2001