diff options
| author | ruki <[email protected]> | 2018-01-16 22:37:14 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2018-01-16 09:43:29 +0800 |
| commit | 4bc80943272b031e41a7047f795d85a04682cbd6 (patch) | |
| tree | 4276043c0055ef7247d5fffd080b3490ccda7a28 | |
| parent | 3b822fc48d1b11055e12463872c22950d2c61b4d (diff) | |
improve select view
| -rw-r--r-- | xmake/core/ui/boxdialog.lua | 3 | ||||
| -rw-r--r-- | xmake/core/ui/button.lua | 2 | ||||
| -rw-r--r-- | xmake/core/ui/dialog.lua | 6 | ||||
| -rw-r--r-- | xmake/core/ui/panel.lua | 8 |
4 files changed, 14 insertions, 5 deletions
diff --git a/xmake/core/ui/boxdialog.lua b/xmake/core/ui/boxdialog.lua index d46b2ed09..7174da28a 100644 --- a/xmake/core/ui/boxdialog.lua +++ b/xmake/core/ui/boxdialog.lua @@ -43,6 +43,9 @@ function boxdialog:init(name, bounds, title) -- resize text self:text():bounds().ey = 3 + + -- select buttons by default + self:panel():select(self:buttons()) end -- get box diff --git a/xmake/core/ui/button.lua b/xmake/core/ui/button.lua index fdbfcbe64..f906e12d8 100644 --- a/xmake/core/ui/button.lua +++ b/xmake/core/ui/button.lua @@ -67,7 +67,7 @@ function button:draw(transparent) local textattr = self:textattr_val() -- selected? - if self:state("selected") then + if self:state("selected") and self:state("focused") then textattr = {textattr, "reverse"} end diff --git a/xmake/core/ui/dialog.lua b/xmake/core/ui/dialog.lua index 4ab34b322..57d94b64b 100644 --- a/xmake/core/ui/dialog.lua +++ b/xmake/core/ui/dialog.lua @@ -87,5 +87,11 @@ function dialog:button_add(name, text, command) return btn end +-- select button from the given button name +function dialog:button_select(name) + self:buttons():select(self:button(name)) + return self +end + -- return module return dialog diff --git a/xmake/core/ui/panel.lua b/xmake/core/ui/panel.lua index e9a3a54ae..3c795a0c0 100644 --- a/xmake/core/ui/panel.lua +++ b/xmake/core/ui/panel.lua @@ -184,9 +184,9 @@ function panel:select(v) if v then -- select and focus this view - v:state_set('selected', true) + v:state_set("selected", true) if self:state("focused") then - v:state_set('focused', true) + v:state_set("focused", true) end end @@ -203,7 +203,7 @@ function panel:select_next(start) end -- get current view - local current = start or self:current() or self:first() + local current = start or self:current() -- select the next view local next = self:next(current) @@ -224,7 +224,7 @@ function panel:select_prev(start) end -- get current view - local current = start or self:current() or self:first() + local current = start or self:current() -- select the previous view local prev = self:prev(current) |
