From 1b3cbfa2e8ebf86322f508f3d8933a0c0386b387 Mon Sep 17 00:00:00 2001
From: Gabriel Tofvesson <gabriel@tofvesson.se>
Date: Tue, 8 Oct 2024 16:21:14 +0200
Subject: [PATCH] Ignore unhandled click events

---
 gfx/element.lua    | 10 +++++++---
 gfx/padding.lua    |  1 -
 itemcontroller.lua |  3 ++-
 3 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/gfx/element.lua b/gfx/element.lua
index ba5efb6..5be36bb 100644
--- a/gfx/element.lua
+++ b/gfx/element.lua
@@ -186,9 +186,13 @@ function Element:redraw()
 end
 
 function Element:handleEvent(evt)
-  if Event.isClickEvent(evt) and self.onClick ~= nil and Event.containsClick(self, evt, 0, 0) then
-    local x, y, source = Event.getClickParams(evt)
-    return not not self.onClick(self, x, y, source)
+  if Event.isClickEvent(evt) and Event.containsClick(self, evt, 0, 0) then
+    if self.onClick ~= nil then
+      local x, y, source = Event.getClickParams(evt)
+      return not not self.onClick(self, x, y, source)
+    else
+      return false
+    end
   end
   return false
 end
diff --git a/gfx/padding.lua b/gfx/padding.lua
index f71a4ff..e4a5b22 100644
--- a/gfx/padding.lua
+++ b/gfx/padding.lua
@@ -90,7 +90,6 @@ function Padding:handleEvent(evt)
   else
     return self.element:handleEvent(evt)
   end
-  return false
 end
 
 function Padding:_reload()
diff --git a/itemcontroller.lua b/itemcontroller.lua
index 33f6d81..a2db066 100644
--- a/itemcontroller.lua
+++ b/itemcontroller.lua
@@ -3,6 +3,7 @@ local ItemGroup = require("storage.itemgroup")
 local Storage = require("storage")
 local Text = require("gfx.text")
 local List = require("gfx.list")
+local Event = require("gfx.event")
 local Padding = require("gfx.padding")
 
 
@@ -147,7 +148,7 @@ local function renderDefault(state, rootElement)
     end
   end
 
-  if not handled then
+  if not handled and not Event.isClickEvent(event) then
     os.queueEvent(table.unpack(event))
   end