StoryWeaver
March 30th, 2019, 14:18
Hi.
I'm trying to solve a particular lua issue for an extension I'm writing. I'm creating some global functionality that will add a radial menu item to many different windows.
In this stripped down implementation what the code does is it overrides the standard Interface.onWindowOpened function correctly, and adds the menu item to the various windows radial menus.
Later on I will filter what particular windows get the menu item by w.getClass().getText() filtering.
This part is all working so far.
However I am unable to capture the menu item selection as I've been unable to make a global override of onMenuSelection() for the windowinstance's the menu item gets added to.
I've tried a few different override attempts such as:
w.onMenuSelection = menuAction;
windowinstance.onMenuSelection = menuAction;
But none have worked so far.
This functionality will be applied to, to many different windows, to make it feasible to copy out and modify the individual xml files for each of those, as it would make it bad to maintain with official updates and make it more likely to clash with other extensions.
function onInit()
Interface.onWindowOpened = windowCheck;
end
function windowCheck(w)
if w == nil then return; end
w.registerMenuItem(Interface.getString("Test"), "Test", 5);
onMenuSelection = menuAction;
end
function menuAction(selection, subselection, subsubselection)
if selection == 5 then
-- do some things
end
end
What am I doing wrong here, how do I capture or register the capture of the override of onMenuSelection for the different window the function interacts with?
Also is there a super() function call I should make in the menuAction function to make sure the regular onMenuSelection functionality runs as well?
I'm trying to solve a particular lua issue for an extension I'm writing. I'm creating some global functionality that will add a radial menu item to many different windows.
In this stripped down implementation what the code does is it overrides the standard Interface.onWindowOpened function correctly, and adds the menu item to the various windows radial menus.
Later on I will filter what particular windows get the menu item by w.getClass().getText() filtering.
This part is all working so far.
However I am unable to capture the menu item selection as I've been unable to make a global override of onMenuSelection() for the windowinstance's the menu item gets added to.
I've tried a few different override attempts such as:
w.onMenuSelection = menuAction;
windowinstance.onMenuSelection = menuAction;
But none have worked so far.
This functionality will be applied to, to many different windows, to make it feasible to copy out and modify the individual xml files for each of those, as it would make it bad to maintain with official updates and make it more likely to clash with other extensions.
function onInit()
Interface.onWindowOpened = windowCheck;
end
function windowCheck(w)
if w == nil then return; end
w.registerMenuItem(Interface.getString("Test"), "Test", 5);
onMenuSelection = menuAction;
end
function menuAction(selection, subselection, subsubselection)
if selection == 5 then
-- do some things
end
end
What am I doing wrong here, how do I capture or register the capture of the override of onMenuSelection for the different window the function interacts with?
Also is there a super() function call I should make in the menuAction function to make sure the regular onMenuSelection functionality runs as well?