Source Code File 14-03_clickput
14-03_clickput.c
#include <ncurses.h> int main() { MEVENT mort; int ch; initscr(); noecho(); keypad(stdscr,TRUE); mousemask(ALL_MOUSE_EVENTS,NULL); while(1) { ch = getch(); if( ch == KEY_MOUSE ) { getmouse(&mort); mvaddch(mort.y,mort.x,'*'); refresh(); continue; } if( ch == '\n' ) break; } endwin(); return(0); }
Output Screenshot
Notes
* This solution is based on the code for 14-02_mspy.c. The difference is that the mvaddch() function sets the asterisk character at the click location. Otherwise, the code is pretty much the same.
Copyright © 1997-2024 by QPBC.
All rights reserved