mouseable views - correction

This commit is contained in:
laelnasan
2020-11-19 13:53:39 -03:00
parent 83031f9516
commit a1f1acff40
3 changed files with 23 additions and 20 deletions

View File

@@ -68,7 +68,7 @@ function boxdialog:init(name, bounds, title)
if curses.KEY_MOUSE then if curses.KEY_MOUSE then
-- set click action -- set click action
self:frame():action_set(ltui.action.ac_on_clicked, function (v, x, y) self:frame():action_set(action.ac_on_clicked, function (v, x, y)
-- return if not mouseable -- return if not mouseable
if not v:option("mouseable") then if not v:option("mouseable") then
@@ -87,7 +87,7 @@ function boxdialog:init(name, bounds, title)
box:bounds():contains(px, py) then box:bounds():contains(px, py) then
-- bypass panel -- bypass panel
return box:action_on(ltui.action.ac_on_clicked, px, py) return box:action_on(action.ac_on_clicked, px, py)
end end
-- return true if it doesn't match any selectable view -- return true if it doesn't match any selectable view

View File

@@ -38,28 +38,31 @@ function button:init(name, bounds, text, on_action)
-- mark as selectable -- mark as selectable
self:option_set("selectable", true) self:option_set("selectable", true)
-- mark as mouseable
self:option_set("mouseable", true)
-- set click action
self:action_set(ltui.action.ac_on_clicked, function (v)
-- return if not mouseable
if not v:option("mouseable") then
return
end
if v:parent()._do_select then
return v:parent():_do_select()
end
return v:action_on(ltui.action.ac_on_enter)
end)
-- show cursor -- show cursor
self:cursor_show(true) self:cursor_show(true)
-- init action -- init action
self:action_set(action.ac_on_enter, on_action) self:action_set(action.ac_on_enter, on_action)
if curses.KEY_MOUSE then
-- mark as mouseable
self:option_set("mouseable", true)
-- set click action
self:action_set(action.ac_on_clicked, function (v)
-- return if not mouseable
if not v:option("mouseable") then
return
end
if v:parent()._do_select then
return v:parent():_do_select()
end
return v:action_on(action.ac_on_enter)
end)
end
end end
-- draw button -- draw button

View File

@@ -67,7 +67,7 @@ function panel:init(name, bounds)
-- try focused first -- try focused first
if v:current() and v:current():bounds():contains(x, y) then if v:current() and v:current():bounds():contains(x, y) then
return v:current():action_on(ltui.action.ac_on_clicked, x, y) return v:current():action_on(action.ac_on_clicked, x, y)
end end
local p = v:last() local p = v:last()