It shouldn't be too hard but not obvious how to help you without seeing how you organized your code. If you created the menubar in a class that extends
Workspace
then there is a variable
workspace
that should give you the information you need about the current window.