WideStudio Programming Guide

| WideStudio Programming Guide | WideStudio Index Table of contents

> ## How to examine which mouse button is pressed

> There is a case to need to examine which the mouse button is pushed in some event procedure. It is possible to get a information of the mouse pointer from the global mouse instance as following program.

>     #include "WScom.h"
>     #include "WSCfunctionList.h"
>     #include "WSCbase.h"
>     //----------------------------------------------------------
>     //Function for the event procedure
>     //----------------------------------------------------------
>     #include "WSDmouse.h" //A

>     void btn_ep(WSCbase* object){
>       long status = WSGIappMouse()->getStatus(); //B
>       if (status & WS_MOUSE_BTN1){ //C
>         //Left button is pushed..
>       }
>       if (status & WS_MOUSE_BTN2){ //D
>         //Middle button is pushed..
>       }
>       if (status & WS_MOUSE_BTN3){ //E
>         //Right button is pushed..
>       }

>     }
>     static WSCfunctionRegister  op("exit_ep",(void*)exit_ep);

> At first,include WSDmouse.h to access the global mouse instance (A). and, get a information of the mouse pointer (B). Check the button of the mouse whether to be pushed (C), (D), (E). It is better that checking value by operator & than ==, because sometime the mouse buttons are pushed in same time.

Document Release 3.20 for WideStudio ver 3.20, Oct 2002

WideStudio documents index | Table of contents

Copyright(C) T. Hirabayashi, 2000-2002 | Last modified: Oct 27, 2002