Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Context menu in custom widget
Context menu in custom widget [message #126558] Tue, 31 March 2009 11:46 Go to next message
Eclipse UserFriend
Originally posted by: haglund86.hotmail.com

Hi!

I want to add a context menu to my custom widget. I've looked at
Qooxdoos example code for creating these menus, but I havent managed to
create one. Does RAP even have support for creating a context menu
inside a custom widget, and if it does, how do I create one? Thanks!
Re: Context menu in custom widget [message #126583 is a reply to message #126558] Tue, 31 March 2009 13:19 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2359
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi Erik,

here is a small example:
1. add contextmenu listener to your JS client implementation
this.addEventListener( "contextmenu", this._onContextMenu, this );
2. use the code below to open the menu
_onContextMenu : function( evt ) {
var menu = this.getContextMenu();
if( menu != null ) {
menu.setLocation( evt.getPageX(), evt.getPageY() );
menu.setOpener( this );
menu.show();
evt.stopPropagation();
}
}
3. set the menu on the server side
Menu menu = new Menu( customWidget );
MenuItem menuItem = new MenuItem( menu , SWT.PUSH );
menuItem.setText( "Menu Item Text" );
customWidget.setMenu( menu );
4. Make sure that you call ControlLCAUtil#preserveValues and
ControlLCAUtil#writeChanges in your CustomWidgetLCA.

Best,
Ivan


Erik Haglund wrote:
> Hi!
>
> I want to add a context menu to my custom widget. I've looked at
> Qooxdoos example code for creating these menus, but I havent managed
> to create one. Does RAP even have support for creating a context menu
> inside a custom widget, and if it does, how do I create one? Thanks!
Re: Context menu in custom widget [message #126593 is a reply to message #126583] Tue, 31 March 2009 15:03 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: haglund86.hotmail.com

Hi Ivan and thanks for your reply.

I don't understand the last step:
4. Make sure that you call ControlLCAUtil#preserveValues and
ControlLCAUtil#writeChanges in your CustomWidgetLCA.

Could you please explain this step a bit more?

//Erik

Ivan Furnadjiev skrev:
> Hi Erik,
>
> here is a small example:
> 1. add contextmenu listener to your JS client implementation
> this.addEventListener( "contextmenu", this._onContextMenu, this );
> 2. use the code below to open the menu
> _onContextMenu : function( evt ) {
> var menu = this.getContextMenu(); if( menu != null ) {
> menu.setLocation( evt.getPageX(), evt.getPageY() );
> menu.setOpener( this );
> menu.show();
> evt.stopPropagation();
> }
> }
> 3. set the menu on the server side
> Menu menu = new Menu( customWidget );
> MenuItem menuItem = new MenuItem( menu , SWT.PUSH );
> menuItem.setText( "Menu Item Text" );
> customWidget.setMenu( menu );
> 4. Make sure that you call ControlLCAUtil#preserveValues and
> ControlLCAUtil#writeChanges in your CustomWidgetLCA.
>
> Best,
> Ivan
>
>
> Erik Haglund wrote:
>> Hi!
>>
>> I want to add a context menu to my custom widget. I've looked at
>> Qooxdoos example code for creating these menus, but I havent managed
>> to create one. Does RAP even have support for creating a context menu
>> inside a custom widget, and if it does, how do I create one? Thanks!
Re: Context menu in custom widget [message #126632 is a reply to message #126593] Tue, 31 March 2009 16:29 Go to previous message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2359
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi Erink,

your custom widget have a LCA - CustomWidgetLCA. In the CustomWidgetLCA
in the method preserveValues call ControlLCAUtil.preserveValues(
customWidget ) and in the method renderChanges call
ControlLCAUtil.writeChanges( customWidget ). Take a look in some of the
existing RAP controls LCAs - ScaleLCA.java for example.

Best,
Ivan

Erik Haglund wrote:
> Hi Ivan and thanks for your reply.
>
> I don't understand the last step:
> 4. Make sure that you call ControlLCAUtil#preserveValues and
> ControlLCAUtil#writeChanges in your CustomWidgetLCA.
>
> Could you please explain this step a bit more?
>
> //Erik
>
> Ivan Furnadjiev skrev:
>> Hi Erik,
>>
>> here is a small example:
>> 1. add contextmenu listener to your JS client implementation
>> this.addEventListener( "contextmenu", this._onContextMenu, this );
>> 2. use the code below to open the menu
>> _onContextMenu : function( evt ) {
>> var menu = this.getContextMenu(); if( menu != null ) {
>> menu.setLocation( evt.getPageX(), evt.getPageY() );
>> menu.setOpener( this );
>> menu.show();
>> evt.stopPropagation();
>> }
>> }
>> 3. set the menu on the server side
>> Menu menu = new Menu( customWidget );
>> MenuItem menuItem = new MenuItem( menu , SWT.PUSH );
>> menuItem.setText( "Menu Item Text" );
>> customWidget.setMenu( menu );
>> 4. Make sure that you call ControlLCAUtil#preserveValues and
>> ControlLCAUtil#writeChanges in your CustomWidgetLCA.
>>
>> Best,
>> Ivan
>>
>>
>> Erik Haglund wrote:
>>> Hi!
>>>
>>> I want to add a context menu to my custom widget. I've looked at
>>> Qooxdoos example code for creating these menus, but I havent managed
>>> to create one. Does RAP even have support for creating a context
>>> menu inside a custom widget, and if it does, how do I create one?
>>> Thanks!
Previous Topic:com.eclipse.rap.demo.feature->ConfigIniCreator Problem
Next Topic:Margin height incorrect sizing
Goto Forum:
  


Current Time: Sun Dec 05 21:40:59 GMT 2021

Powered by FUDForum. Page generated in 0.01891 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top