From 8197d0a6f6cfcfef3bde2c95e06fc6911b5ce77e Mon Sep 17 00:00:00 2001 From: Gabriel Tofvesson Date: Sat, 12 Oct 2024 01:28:46 +0200 Subject: [PATCH] Test click event limits --- itemcontroller.lua | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/itemcontroller.lua b/itemcontroller.lua index 4800230..574a616 100644 --- a/itemcontroller.lua +++ b/itemcontroller.lua @@ -312,6 +312,7 @@ local PAGES = { local group = state:getExtra() if group == nil then + print("No group passed to GROUP_DETAIL") state:setPage("MAIN") return NOOP end @@ -417,7 +418,7 @@ local PAGES = { bgColor = colors.gray }, onClick = function(e, x, y, s) - state:setPage("REQUEST") + state:setPage("REQUEST", group) return true end } @@ -435,19 +436,47 @@ local PAGES = { end, REQUEST = function(state, newPage) - local helloPage = Text:new{ - text = "Hello Request" + local group = state:getExtra() + if group == nil then + print("No group passed to REQUEST") + state:setPage("MAIN") + return NOOP + end + local paddingSide = 0 + local paddingTop = 0 + + local itemName = fitText(group:getSimpleName(), state.width - (paddingSide * 2)) + local itemLeftPad, itemRightPad = getCenterPad(#itemName, state.width - (paddingSide * 2)) + + local paddedTitle = Padding:new{ + top = 1, + left = itemLeftPad, + right = itemRightPad, + bottom = 1, + element = Text:new{ + id = "title", + text = itemName, + bgColor = colors.gray + }, + bgColor = colors.gray, + onClick = function(e, x, y, s) + local title = e:findById("title") + title:setText("Clicked") + local newLeftPad, newRightPad = getCenterPad(#("Clicked"), state.width - (paddingSide * 2)) + e:setPadding{ left = newLeftPad, right = newRightPad } + return true + end } local stuffContainer = Container:new{ [Children:getId()] = { - helloPage + paddedTitle }, width = state.width, height = state.height, parent = state.monitor, onClick = function(e, x, y, s) - state:setPage("GROUP_DETAIL") + state:setPage("GROUP_DETAIL", group) return true end }