ismouseclick


Syntax

#include "graphics.h"

bool ismouseclick(int kind);

Description[WIN]
The ismouseclick function is available in the winbgim implementation of BGI graphics. This function returns true if there is an unprocessed mouse event of the specified kind. The argument to ismouseclick is one of these constants from the graphics.h file:
WM_MOUSEMOVE
if you want to detect a mouse movement
WM_LBUTTONDBLCLK
...detect when the left mouse button is double clicked
WM_LBUTTONDOWN
...detect when the left mouse button is clicked down
WM_LBUTTONUP
...detect when the left mouse button is released up
WM_MBUTTONDBLCLK
...detect when the middle mouse button is double clicked
WM_MBUTTONDOWN
...detect when the middle mouse button is clicked down
WM_MBUTTONUP
...detect when the middle mouse button is released up
WM_RBUTTONDBLCLK
...detect when the right mouse button is double clicked
WM_RBUTTONDOWN
...detect when the right mouse button is clicked down
WM_RBUTTONUP
...detect when the right mouse button is released up

The middle mouse button handlers aren't working on my machine. I haven't yet tracked down the reason--it could be a broken mouse or it could be a bug in my programming.

A mouse event can be processed by calling getmouseclick (which gets the coordinates of the event), or by calling clearmouseclick (which processes the event without providing its coordinates).

Return Value
True if there is an unprocessed mouse event of the specified kind; otherwise false.

See also
getmouseclick
clearmouseclick

Example

/* mouse example */ 

#include "graphics.h"



void main(void)

{

    int maxx, maxy;  // Maximum x and y pixel coordinates

    int x, y;        // Coordinates of the mouse click

    int divisor;     // Divisor for the length of a triangle side



    // Put the machine into graphics mode and get the maximum coordinates:

    initwindow(450, 300);         

    maxx = getmaxx( );

    maxy = getmaxy( );



    // Draw a white circle with red inside and a radius of 50 pixels:

    setfillstyle(SOLID_FILL, RED);

    setcolor(WHITE);

    fillellipse(maxx/2, maxy/2, 50, 50);

    

    // Print a message and wait for a red pixel to be double clicked:

    settextstyle(DEFAULT_FONT, HORIZ_DIR, 2);

    outtextxy(20, 20, "Left click in to end.");

    setcolor(BLUE);

    divisor = 2;

    while (!ismouseclick(WM_LBUTTONDOWN))

    {

        triangle(maxx/divisor, maxy/divisor);

        delay(500);

        divisor++;

    }



    getmouseclick(WM_LBUTTONDOWN, x, y);

    cout << "The mouse was clicked at: ";

    cout << "x=" << x;

    cout << " y=" << y << endl;

    

    // Switch back to text mode:

    closegraph( );

}


Back to index