bevy_editor_prototypes
bevy_editor_prototypes copied to clipboard
Use double-click for the assets explorer
Currently the assets explorer uses a single click to open folder. It wouldn't be a problem if the assets explorer was a tree like Godot, but since it a navigation based file explorer it should use a double-click like Unity or Unreal.
Agreed, I reckon this will need to be part of a selection system: where clicking once select the folder and clicking a second time open it. Selecting item will allow others feature like renaming, deleting, ... Though I'm busy with other stuff atm, I'm planning on coming back to help at some point. Happy for anyone else to give it a go, I can answer question here on on discord, about my crappy code 😄
A small detail, I think double click and clicking a selected folder are pretty different. At least in Windows, KDE Dolphin and Unity, selecting a folder, waiting a bit and clicking again starts rename, not opening that folder, you have to "double click" within some sort of time limit to open that folder.
I think the bevy editor should probably follow this convention.
A small detail, I think double click and clicking a selected folder are pretty different. At least in Windows, KDE Dolphin and Unity, selecting a folder, waiting a bit and clicking again starts rename, not opening that folder, you have to "double click" within some sort of time limit to open that folder.
I think the bevy editor should probably follow this convention.
I've looked into the double-click (and higher-order click) problem in the past.
- Default double-click time on Windows is 500ms, but it's user-configurable and should be queried dynamically for full fidelity.
- For usability, you also need to allow some amount of spatial drift, which is likewise configurable.
Higher-order clicks (beyond double-click) are especially relevant for text selection behavior, which will be needed elsewhere in the editor:
- Single click → place cursor under pointer
- Double click → select word under pointer
- Triple click → select paragraph under pointer
- Quad click → select full buffer
There's a great write-up of how Windows handles higher-order clicks. It keeps only the last click in memory, and for each new click:
- Checks whether it's within the spatial tolerance (
SM_CXDOUBLECLK/SM_CYDOUBLECLK) - Ensures it's within the time threshold (
GetDoubleClickTime) - If so, increments a counter
- Also supports cancellation, e.g. with a right-click
Relevant API docs:
GetDoubleClickTime: default is 500msGetSystemMetricswithSM_CXDOUBLECLK,SM_CYDOUBLECLK: default is 4 pixelsTTM_SETDELAYTIME: tooltip delays are also defined relative to double-click time, and Tooltips are another thing that will be useful in an editor
In my experiments, I took a more general (though potentially less efficient) approach:
I store the last 4 clicks in a FIFO queue — each with timestamp and position — and then query patterns from that. It works well for higher-order click detection.
I did run into some issues with under-clicking followed by over-clicking, but I suspect that might have been due to a Bevy one-frame delay issue.