Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How to display popup menu on LMouseButtonUP ?
How to display popup menu on LMouseButtonUP ? [message #452094] Mon, 14 March 2005 15:48 Go to next message
Eclipse UserFriend
Originally posted by: ncc98011.hotmail.com

Hello all,

In the application I am developing I need to let the user do the following;
press leftMouseButton down, drag, then leftMouseBottomUp -> display popup
menu

That is, the popup menu needs to be displayed after the user releases the
left mouseButton. Does anyone know if this is possible at all in SWT? I have
looked everywhere, but all the sites/book I have consulted don't help...
I've really hit a brick wall here, and am starting to wonder if this is
possible at all.

Any thanks is much appreciated.

Thanks.
Re: How to display popup menu on LMouseButtonUP ? [message #452212 is a reply to message #452094] Tue, 15 March 2005 13:51 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
public static void main (String [] args) {
Display display = new Display ();
Shell shell = new Shell (display);
final Menu menu = new Menu(shell, SWT.POP_UP);
MenuItem item = new MenuItem (menu, SWT.PUSH);
item.setText ("Hello");
shell.addMouseListener(new MouseAdapter() {
Point mouseDown;
public void mouseDown(MouseEvent e) {
if (e.button == 1) {
mouseDown = new Point(e.x, e.y);
}
}
public void mouseUp(MouseEvent e) {
if (e.button == 1) {
if (Math.abs(mouseDown.x - e.x) > 2 ||
Math.abs(mouseDown.y - e.y) > 2) {
menu.setVisible(true);
}
}
mouseDown = null;
}

});

shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}

"Pat Mahon" <ncc98011@hotmail.com> wrote in message
news:d14bs1$33c$1@www.eclipse.org...
> Hello all,
>
> In the application I am developing I need to let the user do the
> following;
> press leftMouseButton down, drag, then leftMouseBottomUp -> display popup
> menu
>
> That is, the popup menu needs to be displayed after the user releases the
> left mouseButton. Does anyone know if this is possible at all in SWT? I
> have
> looked everywhere, but all the sites/book I have consulted don't help...
> I've really hit a brick wall here, and am starting to wonder if this is
> possible at all.
>
> Any thanks is much appreciated.
>
> Thanks.
>
>
Re: How to display popup menu on LMouseButtonUP ? [message #452483 is a reply to message #452212] Mon, 21 March 2005 11:53 Go to previous message
Eclipse UserFriend
Originally posted by: ncc98011.hotmail.com

Thanks very much for your help Veronika - much appreciated. This has solved
my problem :)


"Veronika Irvine" <veronika_irvine@oti.com> wrote in message
news:d16p8k$8su$1@www.eclipse.org...
> public static void main (String [] args) {
> Display display = new Display ();
> Shell shell = new Shell (display);
> final Menu menu = new Menu(shell, SWT.POP_UP);
> MenuItem item = new MenuItem (menu, SWT.PUSH);
> item.setText ("Hello");
> shell.addMouseListener(new MouseAdapter() {
> Point mouseDown;
> public void mouseDown(MouseEvent e) {
> if (e.button == 1) {
> mouseDown = new Point(e.x, e.y);
> }
> }
> public void mouseUp(MouseEvent e) {
> if (e.button == 1) {
> if (Math.abs(mouseDown.x - e.x) > 2 ||
> Math.abs(mouseDown.y - e.y) > 2) {
> menu.setVisible(true);
> }
> }
> mouseDown = null;
> }
>
> });
>
> shell.open ();
> while (!shell.isDisposed ()) {
> if (!display.readAndDispatch ()) display.sleep ();
> }
> display.dispose ();
> }
>
> "Pat Mahon" <ncc98011@hotmail.com> wrote in message
> news:d14bs1$33c$1@www.eclipse.org...
> > Hello all,
> >
> > In the application I am developing I need to let the user do the
> > following;
> > press leftMouseButton down, drag, then leftMouseBottomUp -> display
popup
> > menu
> >
> > That is, the popup menu needs to be displayed after the user releases
the
> > left mouseButton. Does anyone know if this is possible at all in SWT? I
> > have
> > looked everywhere, but all the sites/book I have consulted don't help...
> > I've really hit a brick wall here, and am starting to wonder if this is
> > possible at all.
> >
> > Any thanks is much appreciated.
> >
> > Thanks.
> >
> >
>
>
Previous Topic:SWT Browser - Catching Get / Put
Next Topic:Dates and times handling and validation
Goto Forum:
  


Current Time: Fri Apr 26 04:43:34 GMT 2024

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

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

Back to the top