modules/menusystem : add a way to now the source of a widget action

This commit is contained in:
Kazhnuz 2019-04-07 12:41:19 +02:00
parent 10fb299158
commit 3339e675d3
6 changed files with 12 additions and 12 deletions

View file

@ -113,7 +113,7 @@ function FlowBox:keyreleased(key, code)
if key == "A" then if key == "A" then
if (self.widget.selected >= 1 and self.widget.selected <= #self.widget.list) 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 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 if widget_selected >= 1 and widget_selected <= #self.widget.list then
self.widget.selected = widget_selected self.widget.selected = widget_selected
self:getFocus() self:getFocus()
self.widget.list[self.widget.selected]:action() self.widget.list[self.widget.selected]:action("pointer")
end end
end end

View file

@ -130,7 +130,7 @@ function GridBox:keyreleased(key, code)
end end
if key == "A" and self.widget.selected <= #self.widget.list then 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
end end
@ -201,7 +201,7 @@ function GridBox:mousepressed(x, y, button, isTouch)
self:getFocus() self:getFocus()
if #self.widget.list > 0 and self.widget.selected > 1 and self.widget.selected <= #self.widget.list then 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 end
end end

View file

@ -48,13 +48,13 @@ function HListBox:keyreleased(key, code)
if key == "A" then if key == "A" then
if (self.widget.selected >= 1 and self.widget.selected <= #self.widget.list) 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 end
if key == "B" then if key == "B" then
if (self.widget.cancel >= 1 and self.widget.cancel <= #self.widget.list) 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
end end
@ -76,7 +76,7 @@ function HListBox:mousepressed(x, y, button, isTouch)
self.widget.selected = widget_selected self.widget.selected = widget_selected
self:getFocus() self:getFocus()
if #self.widget.list > 0 then if #self.widget.list > 0 then
self.widget.list[self.widget.selected]:action() self.widget.list[self.widget.selected]:action("pointer")
end end
end end

View file

@ -48,13 +48,13 @@ function ListBox:keyreleased(key, code)
if key == "A" then if key == "A" then
if (self.widget.selected >= 1 and self.widget.selected <= #self.widget.list) 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 end
if key == "B" then if key == "B" then
if (self.widget.cancel >= 1 and self.widget.cancel <= #self.widget.list) 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
end end
@ -76,7 +76,7 @@ function ListBox:mousepressed(x, y, button, isTouch)
self.widget.selected = widget_selected self.widget.selected = widget_selected
self:getFocus() self:getFocus()
if #self.widget.list > 0 then if #self.widget.list > 0 then
self.widget.list[self.widget.selected]:action() self.widget.list[self.widget.selected]:action("pointer")
end end
end end

View file

@ -80,7 +80,7 @@ end
function Menu:cancelAction() function Menu:cancelAction()
if (self.widget.cancel ~= 0) then if (self.widget.cancel ~= 0) then
self.widget.list[self.widget.cancel]:action() self.widget.list[self.widget.cancel]:action("key")
end end
end end

View file

@ -68,7 +68,7 @@ function BaseWidget:update(dt)
-- N/A -- N/A
end end
function BaseWidget:action() function BaseWidget:action(source)
--self:destroy() --self:destroy()
end end