mouseable views - correction 2

This commit is contained in:
laelnasan
2020-11-19 14:17:31 -03:00
parent a1f1acff40
commit be0060b465
3 changed files with 5 additions and 6 deletions

View File

@@ -65,6 +65,7 @@ Notes:
#ifndef LUAJIT
# define LUA_COMPAT_5_1
# define LUA_COMPAT_5_3
# define LUA_COMPAT_ALL
#endif
#include "luaconf.h"

View File

@@ -28,6 +28,7 @@ local program = require("ltui/program")
local desktop = require("ltui/desktop")
local menubar = require("ltui/menubar")
local statusbar = require("ltui/statusbar")
local action = require("ltui/action")
-- define module
local application = application or program()
@@ -88,10 +89,10 @@ function application:on_event(e)
if (not program.on_event(self, e)) and curses.KEY_MOUSE then
-- mouse events
if e.type == ltui.event.ev_mouse and (
if e.type == event.ev_mouse and (
e.btn_name == "BUTTON1_CLICKED" or
e.btn_name == "BUTTON1_DOUBLE_CLICKED") then
self:action_on(ltui.action.ac_on_clicked, e.x, e.y)
self:action_on(action.ac_on_clicked, e.x, e.y)
end
end
end

View File

@@ -82,16 +82,13 @@ function boxdialog:init(name, bounds, title)
local px, py = x - panel:bounds().sx, y - panel:bounds().sy
-- if coordinates don't match any view try box
if panel:action_on(ltui.action.ac_on_clicked, x, y) and
if panel:action_on(action.ac_on_clicked, x, y) and
(not box:option("selectable")) and
box:bounds():contains(px, py) then
-- bypass panel
return box:action_on(action.ac_on_clicked, px, py)
end
-- return true if it doesn't match any selectable view
return true
end)
end
end