f3d icon indicating copy to clipboard operation
f3d copied to clipboard

Add a repeat flag in the binding API

Open Denys619 opened this issue 9 months ago • 3 comments

Is your feature request related to a problem? Please describe. The binding API let libf3d user defines bindings to interact with, however most of these bindings should not support being repeated. Lets add a control for that

Describe the solution you'd like

  • Add a repeat arg to the binding API
  • Implement the feature of not repeating input
  • Add doc and tests

Context Original issue: Input command toggles repeatedly when key is held down #2082

Description When pressing and holding down keys bound to toggle commands (such as toggling the axis visibility ui.axis or other boolean settings), the command rapidly switches its state (on/off/on/off). This causes performance issues, UI flickering, and makes the interaction unpleasant.

To Reproduce Steps to reproduce the behavior:

  1. Launch F3D.
  2. Press and hold a key bound to a toggle command (e.g., axis visibility).

Expected behavior When a toggle key is pressed and held, the state of the command should change only once. Holding the key should not trigger repetitive state changes.

System Information:

  • OS: Ubuntu Linux (24.04.2)
  • F3D: Latest master branch (commit hash 9e9123ec760ad0f465e76a5cf1b9b46baf3bd7eb)

F3D Information

Version: 3.0.0-146-g9e9123ec. Build date: 2025-03-21 18:50:31. Build system: Linux 64-bits. Compiler: GNU 13.3.0. Module ImGui: ON. Module OpenEXR: OFF. Module Raytracing: OFF. VTK version: 9.4.1.

Additional context The key input handling in vtkF3DImguiObserver triggers repeated KeyPress events without checking if the key is already pressed, causing the command to be continuously executed.

I've attempted a preliminary solution by using a keyState map to prevent repeated toggling, but it didn't fully resolve the issue. A more robust approach may be needed at the input handling or event propagation level.

Demonstration I've attached a short video demonstrating this issue clearly.

https://github.com/user-attachments/assets/d67f0588-3ae2-4b1a-835b-2e50cdb7af67

Denys619 avatar Mar 22 '25 06:03 Denys619

Hum, I do not observe any slowdowns when trying to reproduce the issue. Also I'm not sure this behavior is enterely not wanted as some options rely on keep the key pressed down, specifically "L: Increase light intensity".

Maybe we should have a flag by bind to control this behavior ?

What do you think @Meakk ?

mwestphal avatar Mar 24 '25 07:03 mwestphal

Cannot reproduce on macOS but I do on Windows.
I guess it wouldn't hurt to add a repeat flag on the bindings.

Meakk avatar Jun 18 '25 06:06 Meakk

Indeed, that should work.

mwestphal avatar Jun 18 '25 06:06 mwestphal