fix popupmenu, fix mouserelease events, fix connect
This commit is contained in:
parent
8545d15304
commit
c707f990bf
|
@ -22,7 +22,7 @@ function connect(object, signalsAndSlots, pushFront)
|
|||
for signal,slot in pairs(signalsAndSlots) do
|
||||
if not object[signal] then
|
||||
local mt = getmetatable(object)
|
||||
if mt then
|
||||
if mt and type(object) == 'userdata' then
|
||||
object[signal] = function(...)
|
||||
return signalcall(mt[signal], ...)
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
UIPopupMenu = extends(UIWidget)
|
||||
|
||||
local displayedMenuList = {}
|
||||
local currentMenu
|
||||
|
||||
function UIPopupMenu.create()
|
||||
local menu = UIPopupMenu.internalCreate()
|
||||
|
@ -17,10 +17,14 @@ function UIPopupMenu:display(pos)
|
|||
return
|
||||
end
|
||||
|
||||
if currentMenu then
|
||||
currentMenu:destroy()
|
||||
end
|
||||
|
||||
displayUI(self, {x = pos.x, y = pos.y})
|
||||
self:grabMouse()
|
||||
self:grabKeyboard()
|
||||
table.insert(displayedMenuList, self)
|
||||
currentMenu = self
|
||||
end
|
||||
|
||||
function UIPopupMenu:onGeometryChange()
|
||||
|
@ -44,7 +48,9 @@ function UIPopupMenu:addSeparator()
|
|||
end
|
||||
|
||||
function UIPopupMenu:onDestroy()
|
||||
table.removevalue(displayedMenuList, self)
|
||||
if currentMenu == self then
|
||||
currentMenu = nil
|
||||
end
|
||||
end
|
||||
|
||||
function UIPopupMenu:onMousePress(mousePos, mouseButton)
|
||||
|
@ -65,8 +71,8 @@ end
|
|||
|
||||
-- close all menus when the window is resized
|
||||
local function onRootGeometryUpdate()
|
||||
for i,menu in ipairs(displayedMenuList) do
|
||||
menu:destroy()
|
||||
if currentMenu then
|
||||
currentMenu:destroy()
|
||||
end
|
||||
end
|
||||
connect(rootWidget, { onGeometryChange = onRootGeometryUpdate} )
|
||||
|
|
|
@ -79,7 +79,7 @@ void UIManager::inputEvent(const InputEvent& event)
|
|||
case Fw::MousePressInputEvent:
|
||||
m_mouseReceiver->propagateOnMousePress(event.mousePos, event.mouseButton);
|
||||
if(event.mouseButton == Fw::MouseLeftButton)
|
||||
updatePressedWidget(m_rootWidget->recursiveGetChildByPos(event.mousePos), event.mousePos);
|
||||
updatePressedWidget(m_mouseReceiver->recursiveGetChildByPos(event.mousePos), event.mousePos);
|
||||
break;
|
||||
case Fw::MouseReleaseInputEvent:
|
||||
m_mouseReceiver->propagateOnMouseRelease(event.mousePos, event.mouseButton);
|
||||
|
|
Loading…
Reference in New Issue