summaryrefslogtreecommitdiff
path: root/xmake/core/ui/program.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2017-12-23 00:39:37 +0800
committerruki <[email protected]>2017-12-22 21:57:44 +0800
commit9e2b084be73bc0b966c2c43f73403703d64b7228 (patch)
tree5ab95a1343897bde53c6b3f0fedccd6420df7328 /xmake/core/ui/program.lua
parent0f825ce5a225f7dfba8e46e44de82c50df0b2e35 (diff)
handle cm_quit for application
Diffstat (limited to 'xmake/core/ui/program.lua')
-rw-r--r--xmake/core/ui/program.lua15
1 files changed, 15 insertions, 0 deletions
diff --git a/xmake/core/ui/program.lua b/xmake/core/ui/program.lua
index e934e8e54..a79d2af51 100644
--- a/xmake/core/ui/program.lua
+++ b/xmake/core/ui/program.lua
@@ -150,6 +150,16 @@ function program:event_put(e)
table.insert(self._EVENT_QUEUE, e)
end
+-- send command
+function program:send(command, extra)
+ self:event_put(event.command {command, extra})
+end
+
+-- quit program
+function program:quit()
+ self:send("cm_quit")
+end
+
-- run program loop
function program:loop(argv)
@@ -173,6 +183,11 @@ function program:loop(argv)
self:event_on(event.idle())
end
+ -- quit?
+ if e and event.is_command(e, "cm_quit") then
+ break
+ end
+
-- draw views
self:draw()