Context menu in custom widget [message #126558] |
Tue, 31 March 2009 11:46 |
Eclipse User |
|
|
|
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 |
Ivan Furnadjiev Messages: 2427 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 |
Eclipse User |
|
|
|
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 |
Ivan Furnadjiev Messages: 2427 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!
|
|
|
Powered by
FUDForum. Page generated in 0.03052 seconds