summaryrefslogtreecommitdiff
path: root/xmake/core/ui/program.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2020-11-21 00:48:31 +0800
committerruki <[email protected]>2020-11-21 00:48:31 +0800
commit6aa64df1ce672b5d2cd37707d5673089c0a33e3f (patch)
tree41f213925bfe1e7f6d489a5da052bf08aa174c7e /xmake/core/ui/program.lua
parent96ce788dce7a63ab62c47750214f355c9c2eeced (diff)
support mouse for menuconf
Diffstat (limited to 'xmake/core/ui/program.lua')
-rw-r--r--xmake/core/ui/program.lua9
1 files changed, 8 insertions, 1 deletions
diff --git a/xmake/core/ui/program.lua b/xmake/core/ui/program.lua
index c5a73c474..42f5160db 100644
--- a/xmake/core/ui/program.lua
+++ b/xmake/core/ui/program.lua
@@ -25,6 +25,7 @@ local point = require("ui/point")
local panel = require("ui/panel")
local event = require("ui/event")
local curses = require("ui/curses")
+local action = require("ui/action")
-- define module
local program = program or panel()
@@ -45,7 +46,8 @@ function program:init(name, argv)
curses.nl(false)
-- init mouse support
- if curses.KEY_MOUSE then
+ if curses.has_mouse() then
+ -- curses.ALL_MOUSE_EVENTS may be set to mask unused events
curses.mousemask(curses.ALL_MOUSE_EVENTS)
end
@@ -186,6 +188,11 @@ function program:on_event(e)
elseif event.is_command(e, "cm_exit") then
self:quit()
return true
+ -- mouse events
+ elseif e.type == event.ev_mouse and curses.has_mouse() and self:option("mouseable") then
+ if e.btn_name == "BUTTON1_CLICKED" or e.btn_name == "BUTTON1_DOUBLE_CLICKED" then
+ self:action_on(action.ac_on_clicked, e.x, e.y)
+ end
end
end