Delphi Menus & Submenus
This morning I hit a problem with the way events are fired in Delphi menus.
What I wanted was a menu, populated with a set of reports with options to view or edit a report. Rather than forcing the user to expand a submenu everytime they wish to view a particular report I wanted to view the report as soon as the user clicks on the item and provide a sub-menu for each report containing the edit option; i.e. the menu would be structured as follows:
Reports
-> Quotes -> Edit
-> Outstanding Orders -> Edit
-> Completed Orders -> Edit
The problem that I discovered is that the OnClick event of a menu with sub-items is fired when the sub-menu is expanded - even if the user does not click at this point - and no event is fired when the user clicks on the parent item. This resulted in my application trying to produce a report everytime the user hovered over an item in this menu. Ah well, I guess I will just have to add 'View' and 'Edit' into the submenu for each item.
In truth I was a little unsure about using menus in this way any way. I can't imagine many other situations where you would want to create a menu item that both owns a sub-menu and has behaviour of its own. Having a menu containing only one item seems wrong as well. Perhaps there is something somewhere in the Apple Human Interface Guidelines which explictly forbids such a thing!
What I wanted was a menu, populated with a set of reports with options to view or edit a report. Rather than forcing the user to expand a submenu everytime they wish to view a particular report I wanted to view the report as soon as the user clicks on the item and provide a sub-menu for each report containing the edit option; i.e. the menu would be structured as follows:
Reports
-> Quotes -> Edit
-> Outstanding Orders -> Edit
-> Completed Orders -> Edit
The problem that I discovered is that the OnClick event of a menu with sub-items is fired when the sub-menu is expanded - even if the user does not click at this point - and no event is fired when the user clicks on the parent item. This resulted in my application trying to produce a report everytime the user hovered over an item in this menu. Ah well, I guess I will just have to add 'View' and 'Edit' into the submenu for each item.
In truth I was a little unsure about using menus in this way any way. I can't imagine many other situations where you would want to create a menu item that both owns a sub-menu and has behaviour of its own. Having a menu containing only one item seems wrong as well. Perhaps there is something somewhere in the Apple Human Interface Guidelines which explictly forbids such a thing!

0 Comments:
Post a Comment
<< Home