mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-22 23:31:05 +00:00
feat: allow custom mouse click behavior for individual files (#2925)
This commit is contained in:
parent
2768fd22b1
commit
e16c0da547
4 changed files with 18 additions and 24 deletions
|
|
@ -49,19 +49,9 @@ end
|
|||
|
||||
-- Mouse events
|
||||
function Current:click(event, up)
|
||||
if up or event.is_middle then
|
||||
return
|
||||
end
|
||||
|
||||
local f = self._folder
|
||||
local y = event.y - self._area.y + 1
|
||||
if y > #f.window or not f.hovered then
|
||||
return
|
||||
end
|
||||
|
||||
ya.emit("arrow", { y + f.offset - f.hovered.idx })
|
||||
if event.is_right then
|
||||
ya.emit("open", {})
|
||||
if self._folder.window[y] then
|
||||
Entity:new(self._folder.window[y]):click(event, up)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -108,6 +108,18 @@ function Entity:ellipsis(max)
|
|||
end
|
||||
end
|
||||
|
||||
-- Mouse events
|
||||
function Entity:click(event, up)
|
||||
if up or event.is_middle then
|
||||
return
|
||||
end
|
||||
|
||||
ya.emit("reveal", { self._file.url })
|
||||
if event.is_right then
|
||||
ya.emit("open", {})
|
||||
end
|
||||
end
|
||||
|
||||
-- Children
|
||||
function Entity:children_add(fn, order)
|
||||
self._inc = self._inc + 1
|
||||
|
|
|
|||
|
|
@ -31,15 +31,11 @@ end
|
|||
|
||||
-- Mouse events
|
||||
function Parent:click(event, up)
|
||||
if up or not event.is_left then
|
||||
return
|
||||
end
|
||||
|
||||
local y = event.y - self._area.y + 1
|
||||
local window = self._folder and self._folder.window or {}
|
||||
if window[y] then
|
||||
ya.emit("reveal", { window[y].url })
|
||||
else
|
||||
Entity:new(window[y]):click(event, up)
|
||||
elseif not up and event.is_left then
|
||||
ya.emit("leave", {})
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -16,15 +16,11 @@ function Preview:redraw() return {} end
|
|||
|
||||
-- Mouse events
|
||||
function Preview:click(event, up)
|
||||
if up or not event.is_left then
|
||||
return
|
||||
end
|
||||
|
||||
local y = event.y - self._area.y + 1
|
||||
local window = self._folder and self._folder.window or {}
|
||||
if window[y] then
|
||||
ya.emit("reveal", { window[y].url })
|
||||
else
|
||||
Entity:new(window[y]):click(event, up)
|
||||
elseif not up and event.is_left then
|
||||
ya.emit("enter", {})
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue