Skip to content
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

Cancelling of touchpad double-tap dragging by keyboard gets lost #7517

Open
wolfgang371 opened this issue Apr 21, 2024 · 4 comments
Open

Cancelling of touchpad double-tap dragging by keyboard gets lost #7517

wolfgang371 opened this issue Apr 21, 2024 · 4 comments
Labels

Comments

@wolfgang371
Copy link

Version/Branch of Dear ImGui:

1.89.9 master

Back-ends:

crsfml, 2.5.3

Compiler, OS:

gcc/crystal, Ubuntu

Full config/build information:

If you run this and try to drag anything (e.g. a window) and try to cancel it with the keyboard (e.g. by intercepting "Escape") you will have no success when using the touchpad in tapping mode:

puts [ImGui.get_frame_count, ImGui.is_mouse_dragging(:Left) ? "dragging" : nil, ImGui.is_mouse_down(:Left) ? "down" : nil, ImGui.is_key_pressed(ImGuiKey::Escape) ? "Escape" : nil].reject(&.nil?).join(", ")

produces the following...

... with mouse (good)

53, dragging, down
54, dragging, down, Escape
55, dragging, down

... with touchpad & click (good)

316, dragging, down
317, dragging, down, Escape
318, dragging, down

... with touchpad & double-tap (bad)

130, dragging, down
131
132, Escape

Probably that's not an issue of ImGui, but more on the backend / touchpad driver...? then there won't be an easy antidote...

Details:

My Issue/Question:

XXX (please provide as much context as possible)

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

// Here's some code anyone can copy and paste to reproduce your issue
ImGui::Begin("Example Bug");
MoreCodeToExplainMyIssue();
ImGui::End();
@ocornut ocornut added the inputs label May 3, 2024
@ocornut
Copy link
Owner

ocornut commented May 3, 2024

I don't understand what you are talking about, nor what the problem is, nor how it is a dear imgui issue.
Could try rephrasing and explaining this?
What does the Tools->Debug Log->IO log says about inputs submitted to imgui by the backend?

@wolfgang371
Copy link
Author

Sure 😇, sorry

For some reasons the standard ImGui drag-and-drop didn't work for me (I don't recall anymore if it was about specific scrolling of mine or if there was something with the payload), so I investigated something on my own. It also worked out rather easily, it's just that for one border case the cancelling detection didn't succeed. Probably there's nothing ImGui can do about it (but I'm not sure), so that's why I put this ticket.

On a notebook you have at least three ways of doing drag-and-drop:

  1. with an external mouse, as usual (left mouse click&hold, move the mouse)
  2. with a touchpad by click&hold, then move in addition
  3. with a touchpad by double-tap and move this very finger

When you want to abort the drag-and-drop functionality e.g. by pressing "Escape" the Log->IO looks like this:

Touchpad click&hold and move, then in addition "Escape"

[03921] [io] Processed: MousePos (736.0, 347.0) (Mouse)
[03922] [io] Processed: MouseButton 0 Down (Mouse)
[03956] [io] Processed: MousePos (737.0, 347.0) (Mouse)
[...]
[04006] [io] Processed: Key "Escape" Down
[04012] [io] Processed: Key "Escape" Up
[04057] [io] Processed: MouseButton 0 Up (Mouse)
[04101] [io] Processed: MousePos (733.0, 369.0) (Mouse)
[...]

vs.

Touchpad double tap & move, then in addition "Escape"

[08912] [io] Processed: MouseButton 0 Down (Mouse)
[08960] [io] Processed: MousePos (469.0, 644.0) (Mouse)
[...]
[09035] [io] Processed: MousePos (464.0, 630.0) (Mouse)
[09078] [io] Processed: MouseButton 0 Up (Mouse)
[09078] [io] Remaining: Key "Escape" Down
[09079] [io] Processed: Key "Escape" Down
[09082] [io] Processed: Key "Escape" Up
[09123] [io] Processed: MousePos (465.0, 630.0) (Mouse)
[...]

Some strange things happen in double-tab mode:

  • Escape seems to be pressed twice (but isn't)
  • mouse button gets released along with the "first press of Escape.

If you compare this with my initial post...

130, dragging, down
131
132, Escape

.. it seems the "first press" of Escape gets swallowed, producing the sequence "release mouse", empty frame, then "press Escape", which pretty much kills any cancelling detection.

I hope it's clearer now

@ocornut
Copy link
Owner

ocornut commented May 6, 2024

What you mean by cancelling detection? Afaik dear imgui doesn’t have any explicit code in place that poll Escape and has an effect on drag and drop. Based on your sentence you suggest this is completely unrelated to imgui dnd system?

Whatever is submitted to IO is the backend responsibility and is usually a mirror or what the OS submitted to it.

I have no idea what double-tap on your touchpad does but it is worth investigating. Even though it seems unrelated to the scope/responsibility of imgui, if there’s a common feature/idiom submitted by drivers we ought to be aware of it and react if we can, but right now you are sharing inputs not emitted by imgui, i am not sure what i am supposed to do with them.

@wolfgang371
Copy link
Author

Yes, I talk about my own drag-and-drop which I also want to be able to abort e.g. when hitting Escape.
Double-tap is pretty much what you do with your left mouse button when double clicking: two consecutive, quick hits on the touchpad, with the same finger - it doesn't matter where an the pad (but you're not using the click area of the pad). If after the second "tap" you leave the finger at the pad, you're in drag mode - the backend creates the "Mouse button down".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants