user1285928
user1285928

Reputation: 1476

Close all ContextMenu with mouse button

Is there a way to close all opened context menus opened on the scene?

When I press a button I would like to close all Context menus opened by right muse click.

Upvotes: 0

Views: 300

Answers (1)

WillBD
WillBD

Reputation: 1919

Sure, just have some data structure, say a Stack<ContextMenu> Where every time you make a context menu, you push it on the stack, and every time you hide it, you pop it off the stack. Then when you press a certain button, just iterate through the stack and call the .hide() method of contextMenu, on each item i the stack, hiding them as you go, and voila! that should do it.

Upvotes: 3

Related Questions