#include #include int main() { initscr (); cbreak (); noecho (); nonl (); intrflush (stdscr, FALSE); keypad (stdscr, TRUE); meta (stdscr, TRUE); curs_set (0); WINDOW *win1 = newwin (20, 50, 5, 5); PANEL *pan1 = new_panel (win1); box (win1, ACS_VLINE, ACS_HLINE); update_panels (); doupdate (); mmask_t mousemode = BUTTON1_PRESSED | BUTTON1_RELEASED | REPORT_MOUSE_POSITION; MEVENT event; mousemask (mousemode, NULL); bool done = FALSE; int c, ch; while (!done) { ch = getch (); if (ch == KEY_MOUSE) { if (getmouse (&event) != OK) { mvwaddstr (win1, 1, 1, "We got KEY_MOUSE but there was no pending event?!?"); update_panels (); doupdate (); getch (); endwin (); } if (event.bstate & BUTTON1_PRESSED) mvwaddstr (win1, 1, 1, "Down!"); if (event.bstate & BUTTON1_RELEASED) mvwaddstr (win1, 1, 1, "Up! "); if (event.bstate & REPORT_MOUSE_POSITION) mvwaddstr (win1, 1, 1, "Move!"); if (event.bstate & BUTTON1_CLICKED); mvwaddstr (win1, 2, 1, "A click?!?"); update_panels (); doupdate (); } else { mvwaddstr (win1, 3, 1, "That was not a KEY_MOUSE"); update_panels (); doupdate (); done = TRUE; } } getch (); endwin (); }