#include <curses.h>
#include <stdlib.h>

int main()
{
  MEVENT pos;
  int l_maus;
  chtype button;

  initscr();
  noecho();
  keypad(stdscr,TRUE);
  l_maus=mousemask(BUTTON1_RELEASED|BUTTON1_PRESSED|BUTTON1_CLICKED,NULL);

  while(1)
    {
      button=wgetch(stdscr);
      clear();
      if(button==KEY_MOUSE)
        {
          if(getmouse(&pos)==OK)
            {
              if(pos.bstate==BUTTON1_PRESSED) /*linke Maustaste gedrückt bei..*/
                {
                  wenclose(stdscr,pos.y,pos.x);
                  mvwprintw(stdscr,1,0,"linke Maustaste gedrückt bei y = %2d x = %2d",pos.y,pos.x);
                }
             if(pos.bstate==BUTTON1_RELEASED)/*linke Maustaste losgelassen bei....*/
               {
                  mouseinterval(1); /*Reaktionszeit beim loslassen auf 1 Tausendstel Sekunde*/
                  wenclose(stdscr,pos.y,pos.x);
                 mvwprintw(stdscr,2,0,"linke Maustaste losgelassen y = %2d x = %2d",pos.y,pos.x);
               }
            }
        }
      wrefresh(stdscr);
    }
  endwin();
  return 0;
}