WideStudio Programming Guide

| WideStudio Programming Guide | WideStudio Index Table of contents

> ## How to examine which mouse button is pressed

> There is a case need to be examined, in which the mouse button is pushed in some event procedure. It is possible to get information of the mouse pointer from the global mouse instance as the 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 to check value by operator & than ==, because sometimes the mouse buttons are pushed at the same time.

Document Release 3.70 for WideStudio ver 3.70, Feb 2004

WideStudio documents index | Table of contents

Copyright(C) T. Hirabayashi, 2000-2004 | Last modified: Feb 25, 2004