onClick event for top level menu

Is it possible to get onClcik event fired while click the top level menu item??.



For example if i have the following menu



File

New

Open

Exit



Is it possible to have the onClick evet fired while clicking ‘File’ menu item??

If menu item has sub-items it will not generate onClick event, if item has no sub-items it will generate onClick event without relation to its level in menu.
This behavior can be changed if you add next command
    menu.enableWindowOpenMode(false);