![]() |
How to examine which mouse button is pressedThere 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 firust,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 cheking value by operator & than ==, because somethime the mouse buttons are pushed in same time. Document Release 3.0 For Use with Wide Studio Release 3.0, Summer 2002
|