Skip to main content


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 11:57 Go to next message
Andy Coleman is currently offline Andy ColemanFriend
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 15:55 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
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 16:47 Go to previous messageGo to next message
Andy Coleman is currently offline Andy ColemanFriend
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 18:11 Go to previous message
Matt Lumer is currently offline Matt LumerFriend
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 Apr 26 00:09:04 GMT 2024

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

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

Back to the top