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