From 9e2b084be73bc0b966c2c43f73403703d64b7228 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 23 Dec 2017 00:39:37 +0800 Subject: handle cm_quit for application --- xmake/core/ui/program.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'xmake/core/ui/program.lua') 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() -- cgit v1.3.1