Merge pull request #22 from laelnasan/mouse-bugfix

mouseable textedit and block mouse on dialogs
This commit is contained in:
ruki
2020-11-26 10:32:19 +08:00
committed by GitHub
3 changed files with 9 additions and 1 deletions

View File

@@ -63,6 +63,9 @@ function dialog:init(name, bounds, title)
self:buttons():bounds_set(rect:new(0, v:height() - 1, v:width(), 1)) self:buttons():bounds_set(rect:new(0, v:height() - 1, v:width(), 1))
self:_update_buttons_layout() self:_update_buttons_layout()
end) end)
-- mark as block mouse
self:option_set("blockmouse", true)
end end
-- get buttons -- get buttons

View File

@@ -58,7 +58,7 @@ function panel:init(name, bounds)
-- try focused first -- try focused first
local current = v:current() local current = v:current()
if current and current:option("mouseable") and current:bounds():contains(x, y) then if current and current:option("mouseable") and (current:option("blockmouse") or current:bounds():contains(x, y)) then
return current:action_on(action.ac_on_clicked, x, y) return current:action_on(action.ac_on_clicked, x, y)
end end

View File

@@ -26,6 +26,7 @@ local event = require("ltui/event")
local border = require("ltui/border") local border = require("ltui/border")
local curses = require("ltui/curses") local curses = require("ltui/curses")
local textarea = require("ltui/textarea") local textarea = require("ltui/textarea")
local action = require("ltui/action")
-- define module -- define module
local textedit = textedit or textarea() local textedit = textedit or textarea()
@@ -42,6 +43,10 @@ function textedit:init(name, bounds, text)
-- mark as selectable -- mark as selectable
self:option_set("selectable", true) self:option_set("selectable", true)
-- mark as mouseable
self:option_set("mouseable", true)
self:action_set(action.ac_on_clicked, function () return true end)
-- disable progress -- disable progress
self:option_set("progress", false) self:option_set("progress", false)