[Overview][Constants][Types][Procedures and functions][Variables][Index] | Reference for unit 'gpm' (#rtl)

# gpm_getevent

Get event from event queue.

## Declaration

Source position: gpm.pp line 187

`function gpm_getevent(`
`var event: Tgpm_event`
`):LongInt;`

## Description

Gpm_GetEvent Reads an event from the file descriptor gpm_fd. This file is only for internal use and should never be called by a client application.

It returns 1 on success, and -1 on failure.

## Errors

On error, -1 is returned.

## See also

Gpm_GetSnapshot |  | Return servers' current image of mouse state.

## Example

    program gpmex;

    {
      Example program to demonstrate the use of the gpm unit.
    }

    uses gpm;

    var
      connect : TGPMConnect;
      event : tgpmevent;

    begin
      connect.EventMask:=GPM_MOVE or GPM_DRAG or GPM_DOWN or GPM_UP;
      connect.DefaultMask:=0;
      connect.MinMod:=0;
      connect.MaxMod:=0;
      if Gpm_Open(connect,0)=-1 then
        begin
        Writeln('No mouse handler present.');
        Halt(1);
        end;
      Writeln('Click right button to end.');
      Repeat
        gpm_getevent(Event);
        With Event do
          begin
            Write('Pos = (',X,',',Y,') Buttons : (');
            if (buttons and Gpm_b_left)<>0 then
              write('left ');
            if (buttons and Gpm_b_right)<>0 then
              write('right ');
            if (buttons and Gpm_b_middle)<>0 then
              Write('middle ');
            Write(') Event : ');
            Case EventType and $F of
              GPM_MOVE: write('Move');
              GPM_DRAG: write('Drag');
              GPM_DOWN: write('Down');
              GPM_UP: write('Up');
            end;
            Writeln;
          end;
      Until (Event.Buttons and gpm_b_right)<>0;
      gpm_close;
    end.

Documentation generated on: May 14 2021