Do not duplicate RootView method in contextmenu
The method RootView:on_mouse_pressed was copied in the contextmenu plugin with a small modification to intercept the mouse clicks of the active view. This approach is problematic because a relatively large portion of code is duplicated. We introduced a function named RootView.on_view_mouse_pressed to let plugins like contextmenu intercepts mouse clicks in the active area without duplicating the function RootView:on_mouse_pressed.
This commit is contained in:
@@ -738,6 +738,12 @@ function RootView:close_all_docviews()
|
||||
end
|
||||
|
||||
|
||||
-- Function to intercept mouse pressed events on the active view.
|
||||
-- Do nothing by default.
|
||||
function RootView.on_view_mouse_pressed(button, x, y, clicks)
|
||||
end
|
||||
|
||||
|
||||
function RootView:on_mouse_pressed(button, x, y, clicks)
|
||||
local div = self.root_node:get_divider_overlapping_point(x, y)
|
||||
if div then
|
||||
@@ -759,7 +765,9 @@ function RootView:on_mouse_pressed(button, x, y, clicks)
|
||||
end
|
||||
else
|
||||
core.set_active_view(node.active_view)
|
||||
node.active_view:on_mouse_pressed(button, x, y, clicks)
|
||||
if not self.on_view_mouse_pressed(button, x, y, clicks) then
|
||||
node.active_view:on_mouse_pressed(button, x, y, clicks)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user