MenuItems have a wrong order in Menu [message #1060301] |
Fri, 24 May 2013 00:24  |
Eclipse User |
|
|
|
Hello, RAP community!
Try to describe the problem here. If menu has a show event listener which add some menu items in specified positions - they will be added with +1 position shift.
It seems to me the problem is here (Menu.js):
_menuShown : function() {
if( !rwt.remote.EventUtil.getSuspended() ) {
if( this._hasShowListener ) {
// create preliminary item
if( this._preItem == null ) {
this._preItem = new rwt.widgets.MenuItem( "push" );
this._preItem.setText( "..." );
this._preItem.setEnabled( false );
this.addMenuItemAt( this._preItem, 0 );
}
...
}
}
We add the _preItem on show event and hide all menu children for a time.
The listener add some menu items with specified positions - it calls the method Menu.addMenuItemAt(...).
addMenuItemAt : function( menuItem, index ) {
// seperator does not have this function:
if( menuItem.setParentMenu ) {
// it is essential that this happens before the menuItem is added
menuItem.setParentMenu( this );
}
this._layout.addAt( menuItem, index );
}
But the specified position does not correspond the real position in children list, because the _preItem has been added to the top (and it will not be removed) which create +1 position shift.
Thin we must check _preItem in addMenuItemAt to correct insert position.
PS It takes more time to provide a snippet, but I hope my description is clear. The same code works fine in RCP.
Best regards,
Yury.
|
|
|
|
|
Re: MenuItems have a wrong order in Menu [message #1060600 is a reply to message #1060588] |
Mon, 27 May 2013 05:07   |
Eclipse User |
|
|
|
Hi Yury,
yes... you are right. I can reproduce it with RAP from master. Please
open a bugzilla to track the progress on this issue. Please attach the
patch there too.
Thanks,
Ivan
On 5/27/2013 11:09 AM, Yury Mising name wrote:
> Hello, Ivan!
>
> I have created the patch for org.eclipse.rap.demo to reproduce the problem (attached here).
> Steps to reproduce:
> 1. Open About dialog - Help->About. It calls the update method for file menu (in my cases this method is called due to activity management).
> 2. Open File menu -
>
> you will see that "New MenuItem" is the first menu item there, but it was inserted on the second position.
>
> fileMenu.add( new ContributionItem() {
>
> @Override
> public void fill( Menu menu, int index ) {
> MenuItem item = new MenuItem( menu, SWT.PUSH, 1 );
> item.setText( "New MenuItem" );
> }
>
> @Override
> public boolean isDynamic() {
> return true;
> }
> } );
>
>
> If you change the ContributionItem.isDynamic to return false - the item will be inserted correctly.
>
> Best regards,
> Yury.
--
Ivan Furnadjiev
Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/
Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05234 seconds