| WideStudio Programming Guide | WideStudio 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.70 for WideStudio ver 3.70, May 2004

WideStudio documents index | Table of contents

Copyright(C) WideStudio Development Team, 1999-2004 | Last modified: May 25, 2004