-
-
Notifications
You must be signed in to change notification settings - Fork 397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mouse input does not work correctly on urxvt: Moving the cursor always claims the mouse button is clicked. #791
Comments
Hello @psychon Thanks for reporting this I think this was improved ~30 days ago with: Every builtin components have been updated. bool Mouse::IsPressed(Button button) const;
bool Mouse::IsHeld(Button button) const;
bool Mouse::IsReleased(Button button) const; Does the new version satisfies you, or do we need something different? That being said, the example |
Ah, you are right. I was initially experimenting with the latest release and then switched to latest However, "things" still don't seem to work correctly. I switched to the
With Put differently: Yes, I can now interact with the dropdown via the mouse, but things still behave weird / unexpected. I checked out git at |
I found http://pod.tst.eu/http://cvs.schmorp.de/rxvt-unicode/doc/rxvt.7.pod#Mouse_Reporting and the following sub-sections. ftxui seems to enable 1000, 1003, 1015, and 1016. I did some more tests showing the raw input that was received in a human readable form: diff --git a/examples/component/print_key_press.cpp b/examples/component/print_key_press.cpp
index c481271..221f93a 100644
--- a/examples/component/print_key_press.cpp
+++ b/examples/component/print_key_press.cpp
@@ -22,6 +22,9 @@ std::string Stringify(Event event) {
std::string out;
for (auto& it : event.input())
out += " " + std::to_string((unsigned int)it);
+ out += " ";
+ for (auto& it : event.input())
+ out += it;
out = "(" + out + " ) -> ";
if (event.is_character()) { I am just showing the printable part of the above output.
So... the moves are the last button that was pressed with 32 added? With the following proof-of-concept patch, the diff --git a/src/ftxui/component/terminal_input_parser.cpp b/src/ftxui/component/terminal_input_parser.cpp
index 3ba0e69..ec3cc3c 100644
--- a/src/ftxui/component/terminal_input_parser.cpp
+++ b/src/ftxui/component/terminal_input_parser.cpp
@@ -401,6 +401,10 @@ TerminalInputParser::Output TerminalInputParser::ParseMouse( // NOLINT
output.mouse.meta = bool(arguments[0] & 8); // NOLINT
output.mouse.x = arguments[1]; // NOLINT
output.mouse.y = arguments[2]; // NOLINT
+ if (arguments[0] & 32) {
+ // DECMode::kMouseSgrExtMode: This is a move and not a press
+ output.mouse.button = Mouse::Button::None;
+ }
return output;
}
How did I come up with the above? The following part of the urxvt docs (but ignoring the offset since mode 1015 does not include one):
However, if I open a new terminal, newer press a button and move the mouse, I get e.g. I also dug into urxvt's source code. The mouse reporting "stuff" is generated here: http://cvs.schmorp.de/rxvt-unicode/src/command.C?revision=1.603&view=markup#l1353 So... since ftxui enables mode 1006 (kMouseSgrExtMode / PrivMode_ExtMouseSGR), all the docs for urxvt mode do not apply. And I could have actually noticed that the escape sequences above have Edit: Found it. @ArthurSonzogni I hope some of this helps you help me. I never dug into escape sequences before. |
Thanks you very much! You made me realize 3 things:
I start working on something. I will send you a PR. |
- Record whether the mouse moved. Suppress the previous alternative implementation. - Record mouse.control modifier. Fixed:#791
- Record whether the mouse moved. Suppress the previous alternative implementation. - Record mouse.control modifier. Fixed:#791
- Record whether the mouse moved. Suppress the previous alternative implementation. - Record mouse.control modifier. Fixed:#791
Hi,
running the
print_key_press
example inurxvt
and moving the mouse around produces e.g.Notice that this incorrectly claims that the left mouse button is pressed.
The same thing in
xterm
:This issue makes basically anything interactive unusable. E.g. button will trigger every time the cursor moves slightly across it.
The text was updated successfully, but these errors were encountered: