Reputation: 436
I have a MenuBar with objects that have children of type="check". E.g.:
Menu
Menu Item A
/ List item Check 1A
/ List item Check 2A
/ List item Check 3A
Menu Item B
/ List item Check 1B
/ List item Check 2B
My question is as follows: How can i avoid the MenuBar from hiding when the user clicks an item (itemClick event)? I want the user to be able to "check" several items at once, without the menu hiding/closing.
Bonus question: What is the easiest way to reset all the checked items? :-)
Best Regards,
Sebastian
Upvotes: 1
Views: 384
Reputation: 4684
The only way I can advise you is to do monkey patching of the class Menu. I have tried to do it by me, it works as you described in your task.
The main reason to do it is, that the functions we need to redefine use private members of this class. So we can't just override them.
The aim of our mission is to patch the function
function mouseUpHandler(event:MouseEvent):void{...}
At its end you can see the call
hideAllMenus();
We should add a new variable to control whether or not our item is of type "check". So you need to add this line in the beginnig
var isCheck:Boolean = _dataDescriptor.getType(item) == "check";
and this condition at the end
if (!isCheck) hideAllMenus();
Don't forget to do a trick to let your patched class be loaded before the SDK's one. You can read about it here.
Here is my working example. Menu1 has only check items and Menu2 only normal ones.
The whole project can be found here
Upvotes: 1