mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41: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
|
-- Mouse events
|
||||||
function Current:click(event, up)
|
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
|
local y = event.y - self._area.y + 1
|
||||||
if y > #f.window or not f.hovered then
|
if self._folder.window[y] then
|
||||||
return
|
Entity:new(self._folder.window[y]):click(event, up)
|
||||||
end
|
|
||||||
|
|
||||||
ya.emit("arrow", { y + f.offset - f.hovered.idx })
|
|
||||||
if event.is_right then
|
|
||||||
ya.emit("open", {})
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -108,6 +108,18 @@ function Entity:ellipsis(max)
|
||||||
end
|
end
|
||||||
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
|
-- Children
|
||||||
function Entity:children_add(fn, order)
|
function Entity:children_add(fn, order)
|
||||||
self._inc = self._inc + 1
|
self._inc = self._inc + 1
|
||||||
|
|
|
||||||
|
|
@ -31,15 +31,11 @@ end
|
||||||
|
|
||||||
-- Mouse events
|
-- Mouse events
|
||||||
function Parent:click(event, up)
|
function Parent:click(event, up)
|
||||||
if up or not event.is_left then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local y = event.y - self._area.y + 1
|
local y = event.y - self._area.y + 1
|
||||||
local window = self._folder and self._folder.window or {}
|
local window = self._folder and self._folder.window or {}
|
||||||
if window[y] then
|
if window[y] then
|
||||||
ya.emit("reveal", { window[y].url })
|
Entity:new(window[y]):click(event, up)
|
||||||
else
|
elseif not up and event.is_left then
|
||||||
ya.emit("leave", {})
|
ya.emit("leave", {})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -16,15 +16,11 @@ function Preview:redraw() return {} end
|
||||||
|
|
||||||
-- Mouse events
|
-- Mouse events
|
||||||
function Preview:click(event, up)
|
function Preview:click(event, up)
|
||||||
if up or not event.is_left then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local y = event.y - self._area.y + 1
|
local y = event.y - self._area.y + 1
|
||||||
local window = self._folder and self._folder.window or {}
|
local window = self._folder and self._folder.window or {}
|
||||||
if window[y] then
|
if window[y] then
|
||||||
ya.emit("reveal", { window[y].url })
|
Entity:new(window[y]):click(event, up)
|
||||||
else
|
elseif not up and event.is_left then
|
||||||
ya.emit("enter", {})
|
ya.emit("enter", {})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue