double-click support #395
afrantisak
started this conversation in
Ideas
Replies: 2 comments
-
Yep, it is planned. |
Beta Was this translation helpful? Give feedback.
0 replies
-
In the meantime, you can do something like this. In my case, I wanted my DirectoryTree to have the double click effect only on files. You can adjust this idea to whatever you need. class DoubleClickDirectoryTree(DirectoryTree):
"""Instance of DirectoryTree requiring double click to open files"""
def __init__(self, path: str, name: str = None) -> None:
# Set the time to -2 seconds to avoid meeting immediate double click condition
self.last_file_click: Tuple[float, DirEntry] = (
time() - 2,
DirEntry(None, False),
)
super().__init__(path, name)
async def handle_tree_click(self, message: TreeClick[DirEntry]) -> None:
dir_entry = message.node.data
if not dir_entry.is_dir:
# Get the current time and file entry
current_click = (time(), dir_entry)
# If the time difference is less than 1.5 seconds, it's a "double click"
if (
current_click[0] - self.last_file_click[0] < 1.5
and current_click[1] == self.last_file_click[1]
):
await self.emit(FileClick(self, dir_entry.path))
self.last_file_click = current_click
else:
if not message.node.loaded:
await self.load_directory(message.node)
await message.node.expand()
else:
await message.node.toggle() |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I don't see any double-click support... is that on the radar yet?
Beta Was this translation helpful? Give feedback.
All reactions