From 3339e675d39dfe34f0f112a58dc3c069877944bc Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 7 Apr 2019 12:41:19 +0200 Subject: [PATCH] modules/menusystem : add a way to now the source of a widget action --- gamecore/modules/menusystem/flowbox.lua | 4 ++-- gamecore/modules/menusystem/grid.lua | 4 ++-- gamecore/modules/menusystem/hlistbox.lua | 6 +++--- gamecore/modules/menusystem/listbox.lua | 6 +++--- gamecore/modules/menusystem/parent.lua | 2 +- gamecore/modules/menusystem/widgets/init.lua | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/gamecore/modules/menusystem/flowbox.lua b/gamecore/modules/menusystem/flowbox.lua index a120f80..8281046 100644 --- a/gamecore/modules/menusystem/flowbox.lua +++ b/gamecore/modules/menusystem/flowbox.lua @@ -113,7 +113,7 @@ function FlowBox:keyreleased(key, code) if key == "A" then if (self.widget.selected >= 1 and self.widget.selected <= #self.widget.list) then - self.widget.list[self.widget.selected]:action() + self.widget.list[self.widget.selected]:action("key") end end end @@ -145,7 +145,7 @@ function FlowBox:mousepressed(x, y, button, isTouch) if widget_selected >= 1 and widget_selected <= #self.widget.list then self.widget.selected = widget_selected self:getFocus() - self.widget.list[self.widget.selected]:action() + self.widget.list[self.widget.selected]:action("pointer") end end diff --git a/gamecore/modules/menusystem/grid.lua b/gamecore/modules/menusystem/grid.lua index 7dec4b3..46d4759 100644 --- a/gamecore/modules/menusystem/grid.lua +++ b/gamecore/modules/menusystem/grid.lua @@ -130,7 +130,7 @@ function GridBox:keyreleased(key, code) end if key == "A" and self.widget.selected <= #self.widget.list then - self.widget.list[self.widget.selected]:action() + self.widget.list[self.widget.selected]:action("key") end end @@ -201,7 +201,7 @@ function GridBox:mousepressed(x, y, button, isTouch) self:getFocus() if #self.widget.list > 0 and self.widget.selected > 1 and self.widget.selected <= #self.widget.list then - self.widget.list[self.widget.selected]:action() + self.widget.list[self.widget.selected]:action("pointer") end end end diff --git a/gamecore/modules/menusystem/hlistbox.lua b/gamecore/modules/menusystem/hlistbox.lua index 9bccc5b..7f9c667 100644 --- a/gamecore/modules/menusystem/hlistbox.lua +++ b/gamecore/modules/menusystem/hlistbox.lua @@ -48,13 +48,13 @@ function HListBox:keyreleased(key, code) if key == "A" then if (self.widget.selected >= 1 and self.widget.selected <= #self.widget.list) then - self.widget.list[self.widget.selected]:action() + self.widget.list[self.widget.selected]:action("key") end end if key == "B" then if (self.widget.cancel >= 1 and self.widget.cancel <= #self.widget.list) then - self.widget.list[self.widget.cancel]:action() + self.widget.list[self.widget.cancel]:action("key") end end @@ -76,7 +76,7 @@ function HListBox:mousepressed(x, y, button, isTouch) self.widget.selected = widget_selected self:getFocus() if #self.widget.list > 0 then - self.widget.list[self.widget.selected]:action() + self.widget.list[self.widget.selected]:action("pointer") end end diff --git a/gamecore/modules/menusystem/listbox.lua b/gamecore/modules/menusystem/listbox.lua index 944c465..76a4c56 100644 --- a/gamecore/modules/menusystem/listbox.lua +++ b/gamecore/modules/menusystem/listbox.lua @@ -48,13 +48,13 @@ function ListBox:keyreleased(key, code) if key == "A" then if (self.widget.selected >= 1 and self.widget.selected <= #self.widget.list) then - self.widget.list[self.widget.selected]:action() + self.widget.list[self.widget.selected]:action("key") end end if key == "B" then if (self.widget.cancel >= 1 and self.widget.cancel <= #self.widget.list) then - self.widget.list[self.widget.cancel]:action() + self.widget.list[self.widget.cancel]:action("key") end end @@ -76,7 +76,7 @@ function ListBox:mousepressed(x, y, button, isTouch) self.widget.selected = widget_selected self:getFocus() if #self.widget.list > 0 then - self.widget.list[self.widget.selected]:action() + self.widget.list[self.widget.selected]:action("pointer") end end diff --git a/gamecore/modules/menusystem/parent.lua b/gamecore/modules/menusystem/parent.lua index 26561c8..2c0e71e 100644 --- a/gamecore/modules/menusystem/parent.lua +++ b/gamecore/modules/menusystem/parent.lua @@ -80,7 +80,7 @@ end function Menu:cancelAction() if (self.widget.cancel ~= 0) then - self.widget.list[self.widget.cancel]:action() + self.widget.list[self.widget.cancel]:action("key") end end diff --git a/gamecore/modules/menusystem/widgets/init.lua b/gamecore/modules/menusystem/widgets/init.lua index 03006df..dd6ea09 100644 --- a/gamecore/modules/menusystem/widgets/init.lua +++ b/gamecore/modules/menusystem/widgets/init.lua @@ -68,7 +68,7 @@ function BaseWidget:update(dt) -- N/A end -function BaseWidget:action() +function BaseWidget:action(source) --self:destroy() end