Skip to content

Commit

Permalink
Allow RootView:get_active_node to not fallback on the primary node
Browse files Browse the repository at this point in the history
This is useful in case we want to know if no node is active.
  • Loading branch information
Guldoman committed May 22, 2023
1 parent d1e05fb commit 5eed889
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions data/core/rootview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,13 @@ function RootView:defer_draw(fn, ...)
end


---Returns the active node, or the primary one if no node is active.
---
---@param no_fallback boolean #If true, this doesn't return the primary node if no node is active.
---@return core.node
function RootView:get_active_node()
function RootView:get_active_node(no_fallback)
local node = self.root_node:get_node_for_view(core.active_view)
if not node then node = self:get_primary_node() end
if not no_fallback and not node then node = self:get_primary_node() end
return node
end

Expand Down

0 comments on commit 5eed889

Please sign in to comment.