Fix touch method, window offset and return value

This commit is contained in:
Ben 2024-06-01 17:13:03 +02:00
parent 92134a8129
commit de031915f3
Signed by: ben
GPG key ID: 0F54A7ED232D3319
3 changed files with 27 additions and 21 deletions

View file

@ -4,6 +4,7 @@
"term",
"colors",
"fs",
"shell"
"shell",
"window"
]
}

View file

@ -4,11 +4,11 @@ local allTabs = {}
local tabOrder = {}
local currentTab = nil
local function setTerm(new_term)
parent = new_term
local function setTerm(newTerm)
parent = newTerm
end
local function addTab(tab, order_idx)
local function addTab(tab, orderIdx)
assert(tab.name, "tab needs a unique name")
local isCurrentTab = currentTab == nil
if isCurrentTab then
@ -26,7 +26,7 @@ local function addTab(tab, order_idx)
tab.scrollPos = math.max(1, tab.scrollPos - th)
end
allTabs[tab.name] = tab
tabOrder[order_idx] = tab.name
tabOrder[orderIdx] = tab.name
tabCount = tabCount + 1
return tab
end
@ -79,10 +79,12 @@ local function updateSize()
end
end
local function onTouch(touch_x, touch_y)
local function onTouch(touchX, touchY)
if currentTab ~= nil then
currentTab.onTouch(currentTab, touch_x, touch_y)
local winx, winy = currentTab.window.getPosition()
return currentTab.onTouch(currentTab, touchX - winx + 1, touchY - winy + 1)
end
return false
end

View file

@ -54,9 +54,12 @@ local function on_touch(touch_x, touch_y)
tabview.switchTab()
return true
end
elseif tabview.onTouch(touch_x, touch_y) then
elseif tabview_window ~= nil then
local winx, winy = tabview_window.getPosition()
if tabview.onTouch(touch_x-winx+1, touch_y-winy+1) then
return true
end
end
return false
end