1

I have the following code:

#include <ncurses.h>
#include <string.h>

int
main()
{
    int ch;

    initscr();
    noecho();
    cbreak();
    refresh();

    while(1)
    {
        ch = getch();
        addch(ch);
    };

    return 0;
}

It should output something on the screen when the mouse buttons are pressed but it doesn't.

I tried the tips that fixed Mouse movement events in NCurses with no success.

Also when I run htop in the same terminal mouse clicks works. And htop doesn't seem to do anything different, do they? https://github.com/hishamhm/htop/search?q=MOUSE&ref=cmdform

Community
  • 1
  • 1
Michael
  • 148
  • 7

1 Answers1

1

I added mousemask, it works now.

#include <ncurses.h>
#include <string.h>

int
main()
{
    int ch;

    initscr();
    noecho();
    cbreak();
    refresh();
    mousemask(ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION, NULL);

    while(1)
    {
        ch = getch();
        addch(ch);
    };

    return 0;
}
Michael
  • 148
  • 7