/**
* Adds a thin line to the {@link MenuBar} to separate sections of
* {@link MenuItem}s.
*/
public MenuItemSeparator MenuBar.addSeparator();
/**
* Adds a thin line to the {@link MenuBar} to separate sections of
* {@link MenuItem}s.
*/
public void MenuBar.addSeparator(MenuItemSeparator); // Adds a separator, which can be a specialized subclass
/**
* Removes the specified {@link MenuItemSeparator} from the bar.
*/
public void MenuBar.removeSeparator(MenuItemSeparator); // Removes a separator that is already in the MenuBar
/**
* Adds a thin line to the {@link MenuBar} to separate sections of
* {@link MenuItem}s.
*/
public void MenuBar.addSeparator(MenuItemSeparator); // Adds a
separator, which can be a specialized subclass
Should return the passed-in MenuItemSeparator to mirror this method
/**
* Adds a thin line to the {@link MenuBar} to separate sections of
* {@link MenuItem}s.
*/
public MenuItemSeparator MenuBar.addSeparator();
and to support this kind of code:
MenuItemSeparator separator = aMenuBar.addSeparator(new
SpecializedMenuItemSeparator());
which would provide symmetry with this kind of code:
MenuItemSeparator separator = aMenuBar.addSeparator();
Ian
--
Tired of pop-ups, security holes, and spyware?
Try Firefox: http://www.getfirefox.com
Oh. I've never actually used a MenuBar, so I didn't realize
addItem(MenuItem) worked that way. I would suggest changing
addItem(MenuItem) to return the passed-in MenuItem for the same
reasons. Changing a void method to return a MenuItem should be easy
since it's non-breaking, right?
Since I haven't used menus in GWT yet, perhaps you'd like someone
else's comments, too, but I find this construct:
Foo foo = obj.addFoo(new Foo());
more convenient than this:
Foo foo = new Foo();
obj.addFoo(foo);
The extra convenience, for me, is mostly in the reduced line count, so
it's not a big deal one way or the other.
menuBar
.addItem(new MenuItem("Foo", new FooCommand()))
.addSeparator()
.addItem(new MenuItem("Bar", new BarCommand()))
.addItem(new MenuItem("Baz", new BazCommand()));
In practice is there often a need to get a handle on the MenuItem
after it is created? Looking at the API for MenuItem I can't see that
there is much need for the object after it is added to the MenuBar.
This goes doubly for the separator... what method might you need to
call on the separator after it has been added to the MenuBar? I am
sure that there are going to be some edge cases, but I would expect
these to be few compared to the overall usage.
Rob
On Jan 15, 2008 3:03 PM, Bruce Johnson <br...@google.com> wrote:
menuBar.addItem(new MenuItem("Foo", new FooCommand())).addSeparator()
.addItem(new MenuItem("Bar", new BarCommand())).addItem(
new MenuItem("Baz", new BazCommand()));
I certainly will admit that his is a rather weak argument for an API
decision, but it seems to me that this is more a matter of consistency
and convenience than needed functionality.
The void return type doesn't bother me but if I had to choose another
return type, I would choose MenuItemSeparator over MenuBar. I could
see wanting a reference to the separator for modifying style names.
T x = new T()
foo(x)
vs
T x = foo(new T())
On first glance, x is known trivially known to be of type T in the
first, but in the second, x could be any subclass of T and not
neccessarily even the one that was passed in. In both cases, foo can
potentially do mutations or hang onto the reference.
-Ray
In that case the compiler can easily tighten the type of the lvalue
to Y. Not that it cant do it from method calls, only that it can
require more complicated inferences. I'm not sure gwt does these at
the moment.
public MenuItem addItem(MenuItem item)
public MenuItemSeparator addSeparator(MenuItemSeparator separator)
>> On Jan 18, 2008 7:51 AM, Andr�s Testi <andres.a.te...@gmail.com > w