Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Disbale right click popup menu in a Text control
Disbale right click popup menu in a Text control [message #498538] Tue, 17 November 2009 06:57 Go to next message
Andy Coleman is currently offline Andy Coleman
Messages: 33
Registered: September 2009
Member
We are using a Text control for entering an integer value. We have had a request from the users to be able to use the left and right click mouse buttons to increment and decrement the number in the control. Left clicking is not a problem and we have that working. The problem we have though is that when the user right clicks in the edit control they get a pop-up menu containing Cut/Paste/Select All/ etc options. I would like to disable this menu from popping up but cannot see a way of doing it.

Thanks for any help
Andy
Re: Disbale right click popup menu in a Text control [message #498597 is a reply to message #498538] Tue, 17 November 2009 10:55 Go to previous messageGo to next message
Grant Gayed is currently offline Grant Gayed
Messages: 2148
Registered: July 2009
Senior Member
Hi Andy,

text.setMenu(new Menu(text)) will set your own menu with no items, which
stops the OS menu from showing.

As a side note, if your Text is only being used for entering integer values
then you may want to use Spinner.

Grant


"Andy Coleman" <me@andy-coleman.co.uk> wrote in message
news:hdu33p$4ff$1@build.eclipse.org...
> We are using a Text control for entering an integer value. We have had a
request from the users to be able to use the left and right click mouse
buttons to increment and decrement the number in the control. Left clicking
is not a problem and we have that working. The problem we have though is
that when the user right clicks in the edit control they get a pop-up menu
containing Cut/Paste/Select All/ etc options. I would like to disable this
menu from popping up but cannot see a way of doing it.
>
> Thanks for any help
> Andy
Re: Disbale right click popup menu in a Text control [message #498615 is a reply to message #498597] Tue, 17 November 2009 11:47 Go to previous messageGo to next message
Andy Coleman is currently offline Andy Coleman
Messages: 33
Registered: September 2009
Member
Thanks Grant,

That works but a colleague also came up with an alternative

text.addMenuDetectListener(new MenuDetectListener() {
public void menuDetected(MenuDetectEvent e) {
e.doit = false;
}
});

Regards
Andy
Re: Disbale right click popup menu in a Text control [message #1035945 is a reply to message #498615] Sun, 07 April 2013 14:11 Go to previous message
Matt Lumer is currently offline Matt Lumer
Messages: 1
Registered: April 2013
Junior Member
Awesome solution, this really helped!
Previous Topic:StyledText controls
Next Topic:Scale widgets are slow when inside tabs
Goto Forum:
  


Current Time: Fri Aug 01 07:58:19 EDT 2014

Powered by FUDForum. Page generated in 0.01418 seconds