next up previous contents index
Next: GetLastButtonRelease Up: Functions and procedures Previous: Functions and procedures

GetLastButtonPress

   

Declaration:

Function GetLastButtonPress (Button: Longint; Var x,y:Longint) : Longint;

Description:

GetLastButtonPress Stores the position where Button was last pressed in x and y and returns the number of times this button has been pressed since the last call to this function with Button as parameter. For Button you can use the LButton, RButton and MButton constants for resp. the left, right and middle button.

For two-button mice, checking the status of the middle button seems to give and clear the stats of the right button.

Errors:

None.

See also:

GetLastButtonRelease

Example
{example for GetLastButtonPress and GetLastButtonRelease}

Uses Mouse, Crt;

Var x, y, times: Longint;
    c: Char;

Begin
  If MouseFound Then
    Begin
      ClrScr;
      ShowMouse;
      Writeln('Move the mouse and click the buttons (press escape to quit).');
      Writeln('Press the L-key to see the stats for the left button.');
      Writeln('Press the R-key to see the stats for the right button.');
      Writeln('Press the M-key to see the stats for the middle button.');
      GotoXY(1,19);
      Write('Since the last call to GetLastButtonPress with this button as parameter, the');
      GotoXY(1,22);
      Write('Since the last call to GetLastButtonRelease with this button as parameter, the');
      Repeat
        If Keypressed Then
          Begin
            c := UpCase(Readkey);
            Case c Of
              'L':
                Begin
                  GotoXY(1, 20);
                  ClrEol;
                  times := GetLastButtonPress(LButton, x, y);
                  Write('left button has been pressed ',times,
                          ' times, the last time at (',x,',',y,')');
                  times := GetLastButtonRelease(LButton, x, y);
                  GotoXY(1,23);
                  ClrEol;
                  Write('left button has been released ',times,
                          ' times, the last time at (',x,',',y,')')
                End;
              'R':
                Begin
                  GotoXY(1, 20);
                  ClrEol;
                  times := GetLastButtonPress(RButton, x, y);
                  Writeln('right button has been pressed ',times,
                          ' times, the last time at (',x,',',y,')');
                  times := GetLastButtonRelease(RButton, x, y);
                  GotoXY(1,23);
                  ClrEol;
                  Write('right button has been released ',times,
                          ' times, the last time at (',x,',',y,')')
                End;
              'M':
                Begin
                  GotoXY(1, 20);
                  ClrEol;
                  times := GetLastButtonPress(MButton, x, y);
                  Writeln('middle button has been pressed ',times,
                          ' times, the last time at (',x,',',y,')');
                  times := GetLastButtonRelease(MButton, x, y);
                  GotoXY(1,23);
                  ClrEol;
                  Write('middle button has been released ',times,
                          ' times, the last time at (',x,',',y,')')
                End
            End
          End;
      Until (c = #27); {escape}
      While KeyPressed do ReadKey;
      GotoXY(1,24);
      HideMouse
    End
End.



Michael Van Canneyt
Thu Sep 10 13:59:33 CEST 1998