WideStudio/MWT Logo
Programming Guide
WideStudio/MWT 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.90 for WideStudio/MWT ver 3.90, Jul 2005

WideStudio/MWT documents index | Table of contents

Copyright(C) WideStudio/MWT Development Team, 1999-2005 Last modified: Jul 31, 2005