summaryrefslogtreecommitdiff
path: root/xmake/core/ui
diff options
context:
space:
mode:
authorruki <[email protected]>2018-01-17 22:33:14 +0800
committerruki <[email protected]>2018-01-17 09:19:24 +0800
commitd729a22336476e0b8de653d83d0f0bfe7d7b172e (patch)
tree86dca44f59172054b5556989443f688e9c2074d6 /xmake/core/ui
parent4bc80943272b031e41a7047f795d85a04682cbd6 (diff)
fix view:show bug
Diffstat (limited to 'xmake/core/ui')
-rw-r--r--xmake/core/ui/panel.lua15
-rw-r--r--xmake/core/ui/view.lua13
2 files changed, 24 insertions, 4 deletions
diff --git a/xmake/core/ui/panel.lua b/xmake/core/ui/panel.lua
index 3c795a0c0..43c71315e 100644
--- a/xmake/core/ui/panel.lua
+++ b/xmake/core/ui/panel.lua
@@ -147,8 +147,7 @@ function panel:remove(v)
-- select next view
if self:current() == v then
- self._CURRENT = nil
- self:select_next()
+ self:select_next(nil, true)
end
-- invalidate it
@@ -195,13 +194,18 @@ function panel:select(v)
end
-- select the next view
-function panel:select_next(start)
+function panel:select_next(start, reset)
-- is empty?
if self:empty() then
return
end
+ -- reset?
+ if reset then
+ self._CURRENT = nil
+ end
+
-- get current view
local current = start or self:current()
@@ -223,6 +227,11 @@ function panel:select_prev(start)
return
end
+ -- reset?
+ if reset then
+ self._CURRENT = nil
+ end
+
-- get current view
local current = start or self:current()
diff --git a/xmake/core/ui/view.lua b/xmake/core/ui/view.lua
index de301e795..00c27132a 100644
--- a/xmake/core/ui/view.lua
+++ b/xmake/core/ui/view.lua
@@ -232,8 +232,19 @@ function view:resize()
end
-- show view?
-function view:show(visible)
+--
+-- .e.g
+-- v:show(false)
+-- v:show(true, {focused = true})
+--
+function view:show(visible, opt)
if self:state("visible") ~= visible then
+ local parent = self:parent()
+ if parent and parent:current() == self and not visible then
+ parent:select_next(nil, true)
+ elseif parent and visible and opt and opt.focused then
+ parent:select(self)
+ end
self:state_set("visible", visible)
self:invalidate()
end