|
From: Ken O. <ko...@an...> - 2001-02-17 11:28:27
|
David,
> I found the API, well, akward, at least for my purposes.
I've been doing some thinking on what the interface could be. What are your
thoughts on something like:
menuName.addMenuItem( id, type, menuItem, [data], [parent id], [before id],
[group] )
id = a unique identifier
type = "menu", "command", "seperator", "blank"
menuItem = another object with visual info or just a string (in which case a
menuItem is generated)
[data] = some data to store that is passed pack when menu selected (i.e. the
URL)
[parent id] = the ID of the parent if it is not on the root
[before id] = the ID of the item for this choice to be insert before. If
empty, add to the end
[group]= a way of grouping commands - (can be used to diable commands in
groups)
menuItem Class:
.caption = text to display (with & notation for key accelerators (e.g
&File)
.defaultButtonImage (optional - image for whole cell)
.rolloverButtonImage (optional - image for whole cell)
.mouseButtonDownImage (optional - image for whole cell)
.selectedButtonImage (optional - image for whole cell)
.disabledButtonImange (optionl - image when cell disable)
.defaultClass (optional - for CSS link and text cells)
.selectedClass (optional - CSS class when selected)
.disabledClass (optional - CSS class when disabled)
.buttonDownClass (optional - CSS class when pressed)
.rolloverClass(optional - CSS class when mouse on)
.iconSmallImage (optional - small icon to be displayed to left of
caption - just like Windows)
.iconLarge (optional - a bigger icon for ?)
.text (optional string for tool tips or status bar text)
.<positioning info> (optional - to allow for funky menus)
A user would create a menu object (opposed to number of buttons) and then
add menus and choices. For example (to use some familar menu structures):
myMenu = New NavigationWidget(size & positioning stuff for menu)
myMenu.addMenuItem("file", "menu", "&File"); // Create a file menu
myMenu.addMenuItem("filesave", "command", "Save", "FileSave.htm", "file");
// Add choice to menu
myMenu.addMenuItem("edit", "menu", "&Edit"); // Create edit menu
myMenu.addMenuItem("editcopy", "command", "&Copy", "EditCopy.htm", "edit");
myMenu.addMenuItem("view", "menu", "&View"); // Create view menu
myMenu.addMenuItem("next", "menu", "&Next", "view"); // Create sub menu
myMenu.addMenuItem("nextmessage", "command", "&Message", "next",
"ViewNextMessage.htm"); // Add a choice to sub menu
The widget should fire an event and pass the "id" and "data" (URL) when a
choice is selected.
To do something fancier:
myCell = New menuItem("some text", myImage1, myimage2, positions, etc);
myMenu.AddMenuItem("id", "menu", myCell)
I haven't begun to consider implementation (although I've done similar
things in other languages). At the moment, I'm only looking at it from an
interface point of view. If we nail a good interface, other developers
might adopt it. It would be great if one had a choice of many different
menu systems and it was trivial to switch between them.
What are your thoughts?
Regards,
Ken
|