diff options
| author | ruki <[email protected]> | 2018-01-23 00:47:20 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2018-01-22 22:44:03 +0800 |
| commit | ac234fd5eb079d9e21485ac7d4b06c2c30d2db2a (patch) | |
| tree | b1e636c11fb9a4128f00f71a42f9c3b07a0fae64 /xmake/core/ui/dialog.lua | |
| parent | 6d116a4bc1b58f660a60ff206c6c57ee9c939805 (diff) | |
add exit command
Diffstat (limited to 'xmake/core/ui/dialog.lua')
| -rw-r--r-- | xmake/core/ui/dialog.lua | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/xmake/core/ui/dialog.lua b/xmake/core/ui/dialog.lua index b6a138e20..440f9219a 100644 --- a/xmake/core/ui/dialog.lua +++ b/xmake/core/ui/dialog.lua @@ -25,6 +25,7 @@ -- load modules local log = require("ui/log") local rect = require("ui/rect") +local event = require("ui/event") local label = require("ui/label") local panel = require("ui/panel") local button = require("ui/button") @@ -94,5 +95,25 @@ function dialog:button_select(name) return self end +-- quit dialog +function dialog:quit() + local parent = self:parent() + if parent then + local action = self:action("command.exit") + if action then + action(self, event.command {"cm_exit"}) + end + parent:remove(self) + end +end + +-- on event +function dialog:event_on(e) + if e.type == event.ev_keyboard and e.key_name == "Esc" then + self:quit() + return true + end +end + -- return module return dialog |
