Mouse input from PDCurses application not working #10573

Open
opened 2026-01-31 02:24:55 +00:00 by claunia · 0 comments
Owner

Originally created by @thomthom on GitHub (Sep 10, 2020).

Environment

Windows build number: Microsoft Windows [Version 10.0.19041.450]
Windows Terminal version (if applicable): 1.2.2381.0

Any other software?
PDCurses: https://github.com/wmcbrine/PDCurses @ 618e0aa

Steps to reproduce

# CMakeLists.txt
cmake_minimum_required(VERSION 3.17)

project(CursesTest VERSION 0.1.0 LANGUAGES CXX C)

find_package(Curses REQUIRED)

set(MOUSECURSE_SOURCES
  mousecurse.cpp
)

add_executable(mousecurse ${MOUSECURSE_SOURCES})
target_link_libraries(mousecurse
  curses
)
target_compile_definitions(mousecurse PRIVATE PDC_NCMOUSE)
// mousecurse.cpp
#include <iomanip>
#include <iostream>

#include <curses.h>

void print_input(int input);

int main()
{
  initscr();
  raw();
  keypad(stdscr, TRUE);
  noecho();

  mousemask(BUTTON1_CLICKED, nullptr);

  move(1, 1);
  attron(A_BOLD);
  printw("PDCurses Mouse Test");
  attroff(A_BOLD);

  bool run = true;
  while(run) {
    refresh();
    int input = getch();

    switch(input) {
    case 'q':
      run = false;
      break;
    default:
      print_input(input);
    }
  }

  endwin();
  return 0;
}

void print_input(int input)
{
  move(3, 1);
  clrtoeol();
  printw("The pressed key is ");
  attron(A_BOLD);
  if (input & KEY_CODE_YES) {
    const char* name = keyname(input);
    printw("%i (%s)", input, name);

  } else if (input == KEY_MOUSE) {
    MEVENT event{};
    if(getmouse(&event) == OK) {
      const char* name = keyname(input);
      printw("%i (%s) [x: %i, y: %i, state: %lu]",
          input, name, event.x, event.y, event.bstate);
    }

  } else {
    printw("%i (%c)", input, input);
  }
  attroff(A_BOLD);
}

Expected behavior

I'm expecting the receive mouse input to the application. This works in normal cmd.exe:

mousecurse-cmd

Actual behavior

In Windows Terminal the mouse events doesn't reach the application, instead a text selection is made:

mousecurse-winterm

Originally created by @thomthom on GitHub (Sep 10, 2020). # Environment ```none Windows build number: Microsoft Windows [Version 10.0.19041.450] Windows Terminal version (if applicable): 1.2.2381.0 ``` Any other software? PDCurses: https://github.com/wmcbrine/PDCurses @ [618e0aa](https://github.com/wmcbrine/PDCurses/commit/618e0aaa31b4728eb4df78ec4de6c2b873908eda) # Steps to reproduce ```cmake # CMakeLists.txt cmake_minimum_required(VERSION 3.17) project(CursesTest VERSION 0.1.0 LANGUAGES CXX C) find_package(Curses REQUIRED) set(MOUSECURSE_SOURCES mousecurse.cpp ) add_executable(mousecurse ${MOUSECURSE_SOURCES}) target_link_libraries(mousecurse curses ) target_compile_definitions(mousecurse PRIVATE PDC_NCMOUSE) ``` ```cpp // mousecurse.cpp #include <iomanip> #include <iostream> #include <curses.h> void print_input(int input); int main() { initscr(); raw(); keypad(stdscr, TRUE); noecho(); mousemask(BUTTON1_CLICKED, nullptr); move(1, 1); attron(A_BOLD); printw("PDCurses Mouse Test"); attroff(A_BOLD); bool run = true; while(run) { refresh(); int input = getch(); switch(input) { case 'q': run = false; break; default: print_input(input); } } endwin(); return 0; } void print_input(int input) { move(3, 1); clrtoeol(); printw("The pressed key is "); attron(A_BOLD); if (input & KEY_CODE_YES) { const char* name = keyname(input); printw("%i (%s)", input, name); } else if (input == KEY_MOUSE) { MEVENT event{}; if(getmouse(&event) == OK) { const char* name = keyname(input); printw("%i (%s) [x: %i, y: %i, state: %lu]", input, name, event.x, event.y, event.bstate); } } else { printw("%i (%c)", input, input); } attroff(A_BOLD); } ``` # Expected behavior I'm expecting the receive mouse input to the application. This works in normal `cmd.exe`: ![mousecurse-cmd](https://user-images.githubusercontent.com/192418/92738958-b405e180-f37c-11ea-9f62-061a7ac46031.gif) # Actual behavior In Windows Terminal the mouse events doesn't reach the application, instead a text selection is made: ![mousecurse-winterm](https://user-images.githubusercontent.com/192418/92739049-c718b180-f37c-11ea-871c-0b565ac9736a.gif)
claunia added the Resolution-Duplicate label 2026-01-31 02:24:55 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#10573