From f468f873bda2ace981421667b43bb14e1c93b74b Mon Sep 17 00:00:00 2001 From: comphilip Date: Sat, 22 Jan 2022 01:28:04 +0800 Subject: [PATCH] Support non-touch device to choose file or folder (#8696) ## Background `pathchooser.lua` does not support non-touch device to choose file or folder due to those device cannot generate long press event. ## Choose File Non-touch device can select file in list, it is good enough to choose file without long press to confirm. ## Choose Folder `pathchooser.lua` changes the label of current directory `.` to `Long-press to choose a folder`. It is user friendly, while for non-device, it is a very good place to let user tell the system I want the current folder to be chosen without extra long press. --- frontend/ui/widget/pathchooser.lua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/frontend/ui/widget/pathchooser.lua b/frontend/ui/widget/pathchooser.lua index ea210b408..c1bf25d06 100644 --- a/frontend/ui/widget/pathchooser.lua +++ b/frontend/ui/widget/pathchooser.lua @@ -1,5 +1,6 @@ local BD = require("ui/bidi") local ButtonDialogTitle = require("ui/widget/buttondialogtitle") +local Device = require("device") local FileChooser = require("ui/widget/filechooser") local UIManager = require("ui/uimanager") local ffiutil = require("ffi/util") @@ -51,6 +52,9 @@ end function PathChooser:onMenuSelect(item) local path = item.path if path:sub(-2, -1) == "/." then -- with show_current_dir_for_hold + if not Device:isTouchDevice() and self.select_directory then -- let non-touch device can select the folder + return self:onMenuHold(item) + end -- Don't navigate to same directory return true end @@ -68,6 +72,9 @@ function PathChooser:onMenuSelect(item) return true end if attr.mode ~= "directory" then + if not Device:isTouchDevice() and self.select_file then -- let non-touch device can select the file + return self:onMenuHold(item) + end -- Do nothing if Tap on other than directories return true end