disable mouse for view by default
This commit is contained in:
@@ -66,6 +66,7 @@ function boxdialog:init(name, bounds, title)
|
||||
end)
|
||||
|
||||
-- on click for frame
|
||||
self:option_set("mouseable", true)
|
||||
self:frame():action_set(action.ac_on_clicked, function (v, x, y)
|
||||
|
||||
-- get relative coordinates
|
||||
|
@@ -42,6 +42,7 @@ function button:init(name, bounds, text, on_action)
|
||||
self:cursor_show(true)
|
||||
|
||||
-- init actions
|
||||
self:option_set("mouseable", true)
|
||||
self:action_set(action.ac_on_enter, on_action)
|
||||
self:action_set(action.ac_on_clicked, function (v)
|
||||
-- FIXME
|
||||
|
@@ -211,5 +211,10 @@ function curses.cursor_set(state)
|
||||
end
|
||||
end
|
||||
|
||||
-- has mouse?
|
||||
function curses.has_mouse()
|
||||
return curses.KEY_MOUSE and true or false
|
||||
end
|
||||
|
||||
-- return module: curses
|
||||
return curses
|
||||
|
@@ -50,6 +50,7 @@ function panel:init(name, bounds)
|
||||
self._VIEWS_CACHE = {}
|
||||
|
||||
-- on click action
|
||||
self:option_set("mouseable", true)
|
||||
self:action_set(action.ac_on_clicked, function (v, x, y)
|
||||
|
||||
-- get relative coordinates
|
||||
|
@@ -189,7 +189,7 @@ function program:on_event(e)
|
||||
self:quit()
|
||||
return true
|
||||
-- mouse events
|
||||
elseif e.type == event.ev_mouse and self:option("mouseable") then
|
||||
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
|
||||
|
@@ -68,7 +68,7 @@ function view:init(name, bounds)
|
||||
-- init options
|
||||
local options = object()
|
||||
options.selectable = false -- true if window can be selected
|
||||
options.mouseable = curses.KEY_MOUSE and true or false -- enable it by default
|
||||
options.mouseable = false -- false by default
|
||||
self._OPTIONS = options
|
||||
|
||||
-- init attributes
|
||||
|
Reference in New Issue
Block a user