Send mouseleft event when the mouse leaves the window (#928)
* Send `mouseleft` event when the mouse leaves the window * Call `View:on_mouse_left` when the mouse leaves the `View` Previously `View:on_mouse_left` was called only when the mouse left the window, and it was called on every visible `View`. Now it gets also called when the mouse "changes" `View`, and only the last `View` the mouse was on will receive the event.
This commit is contained in:
@@ -256,8 +256,13 @@ function RootView:on_mouse_moved(x, y, dx, dy)
|
||||
|
||||
self.root_node:on_mouse_moved(x, y, dx, dy)
|
||||
|
||||
local last_overlapping_node = self.overlapping_node
|
||||
self.overlapping_node = self.root_node:get_child_overlapping_point(x, y)
|
||||
|
||||
if last_overlapping_node and last_overlapping_node ~= self.overlapping_node then
|
||||
last_overlapping_node:on_mouse_left()
|
||||
end
|
||||
|
||||
local div = self.root_node:get_divider_overlapping_point(x, y)
|
||||
local tab_index = self.overlapping_node and self.overlapping_node:get_tab_overlapping_point(x, y)
|
||||
if self.overlapping_node and self.overlapping_node:get_scroll_button_index(x, y) then
|
||||
@@ -272,6 +277,13 @@ function RootView:on_mouse_moved(x, y, dx, dy)
|
||||
end
|
||||
|
||||
|
||||
function RootView:on_mouse_left()
|
||||
if self.overlapping_node then
|
||||
self.overlapping_node:on_mouse_left()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function RootView:on_file_dropped(filename, x, y)
|
||||
local node = self.root_node:get_child_overlapping_point(x, y)
|
||||
return node and node.active_view:on_file_dropped(filename, x, y)
|
||||
|
||||
Reference in New Issue
Block a user