Skip to content

Commit a7db005

Browse files
committed
Handle clicks on_mouse_pressed not commands
Handling the clicks as commands doesn't takes cares of checking the coordinates and requires registering additional commands just for that purpose plus causes issues as in pragtical/pragtical#353
1 parent 45e0229 commit a7db005

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

plugins/plugin_manager/plugin_view.lua

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,26 @@ function PluginView:on_mouse_pressed(button, mx, my, clicks)
100100
x = x + self.widths[i] + style.padding.x
101101
end
102102
end
103+
if
104+
mx < self.position.x or mx > self.position.x + self.size.x
105+
or
106+
my < self.position.y or my > self.position.y + self.size.y
107+
then
108+
return false
109+
end
110+
if button == "left" and clicks == 1 and self.hovered_plugin then
111+
self.selected_plugin, self.selected_plugin_idx = self.hovered_plugin, self.hovered_plugin_idx
112+
return true
113+
elseif button == "left" and clicks == 2 and self.selected_plugin then
114+
local status = self.selected_plugin.status
115+
if status == "available" then
116+
self:install(self.selected_plugin)
117+
return true
118+
elseif status == "installed" or status == "orphan" or status == "bundled" then
119+
self:uninstall(self.selected_plugin)
120+
return true
121+
end
122+
end
103123
return false
104124
end
105125

@@ -451,11 +471,9 @@ keymap.add {
451471
["pageup"] = "plugin-manager:scroll-page-up",
452472
["home"] = "plugin-manager:scroll-page-top",
453473
["end"] = "plugin-manager:scroll-page-bottom",
454-
["lclick"] = "plugin-manager:select",
455474
["ctrl+f"] = "plugin-manager:filter",
456475
["ctrl+r"] = "plugin-manager:refresh-all",
457476
["ctrl+u"] = "plugin-manager:upgrade-all",
458-
["2lclick"] = { "plugin-manager:install-selected", "plugin-manager:uninstall-selected" },
459477
["return"] = { "plugin-manager:install-selected", "plugin-manager:uninstall-selected" },
460478
["escape"] = "plugin-manager:clear-filter",
461479
}

0 commit comments

Comments
 (0)