Skip to main content



      Home
Home » Eclipse Projects » GEF » popup menu on a figure
popup menu on a figure [message #80055] Mon, 19 May 2003 11:39 Go to next message
Eclipse UserFriend
Originally posted by: laubi.nicely.ch

hi!

I've got the following code:
RectangleFigure node1 = new RectangleFigure();
node1.addMouseListener(new MouseListener.Stub() {
public void mousePressed(MouseEvent event) {
if (event.button == 3) {
classMenu.setVisible(true);
}
}
});

classMenu = new Menu (shell, SWT.POP_UP);
item = new MenuItem (classMenu, SWT.PUSH);
item.setText ("Delete");
classMenu.addListener (SWT.Show, new Listener () {
public void handleEvent (Event event) {
System.out.println("here we are..");
}
});

this works well, but when the popup menu is shown I must know which control
was "active" (the object that the user has pushed..).. When I call a
function (not implemented in the source code above) from the menu (as an
example "delete") I have to know which control I should remove... What's the
best way to do this?

thanks for any help!

Remo
Re: popup menu on a figure [message #80075 is a reply to message #80055] Mon, 19 May 2003 13:24 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

Popup menus should be done by creating a Menu and setting it as the context
menu on a control. (setMenu(Menu))

"Remo Laubacher" <laubi@nicely.ch> wrote in message
news:baatvt$c66$1@rogue.oti.com...
> hi!
>
> I've got the following code:
> RectangleFigure node1 = new RectangleFigure();
> node1.addMouseListener(new MouseListener.Stub() {
> public void mousePressed(MouseEvent event) {
> if (event.button == 3) {
> classMenu.setVisible(true);
> }
> }
> });
>
> classMenu = new Menu (shell, SWT.POP_UP);
> item = new MenuItem (classMenu, SWT.PUSH);
> item.setText ("Delete");
> classMenu.addListener (SWT.Show, new Listener () {
> public void handleEvent (Event event) {
> System.out.println("here we are..");
> }
> });
>
> this works well, but when the popup menu is shown I must know which
control
> was "active" (the object that the user has pushed..).. When I call a
> function (not implemented in the source code above) from the menu (as an
> example "delete") I have to know which control I should remove... What's
the
> best way to do this?
>
> thanks for any help!
>
> Remo
>
>
>
Re: popup menu on a figure [message #80088 is a reply to message #80075] Mon, 19 May 2003 14:57 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: laubi.nicely.ch

yes, but RectangleFigure doesn't have such a method.. (Eclipse 200303272130
WinXP)

"Randy Hudson" <none@us.ibm.com> wrote in message
news:bab415$hh0$1@rogue.oti.com...
> Popup menus should be done by creating a Menu and setting it as the
context
> menu on a control. (setMenu(Menu))
>
> "Remo Laubacher" <laubi@nicely.ch> wrote in message
> news:baatvt$c66$1@rogue.oti.com...
> > hi!
> >
> > I've got the following code:
> > RectangleFigure node1 = new RectangleFigure();
> > node1.addMouseListener(new MouseListener.Stub() {
> > public void mousePressed(MouseEvent event) {
> > if (event.button == 3) {
> > classMenu.setVisible(true);
> > }
> > }
> > });
> >
> > classMenu = new Menu (shell, SWT.POP_UP);
> > item = new MenuItem (classMenu, SWT.PUSH);
> > item.setText ("Delete");
> > classMenu.addListener (SWT.Show, new Listener () {
> > public void handleEvent (Event event) {
> > System.out.println("here we are..");
> > }
> > });
> >
> > this works well, but when the popup menu is shown I must know which
> control
> > was "active" (the object that the user has pushed..).. When I call a
> > function (not implemented in the source code above) from the menu (as an
> > example "delete") I have to know which control I should remove... What's
> the
> > best way to do this?
> >
> > thanks for any help!
> >
> > Remo
> >
> >
> >
>
>
Re: popup menu on a figure [message #80099 is a reply to message #80088] Mon, 19 May 2003 15:42 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

Neither does TreeItem. Figures are not meant to be lightweight versions of
SWT Controls. There is no short definition, but they are objects which
layout, paint, and can be hit-tested.

If you want to include the concept of selection, this is one thing that GEF
adds to draw2d. An EditPart is the unit of selection, and EditPartViewers
maintain the set of selected editparts.

"Remo Laubacher" <laubi@nicely.ch> wrote in message
news:bab9iv$mcd$1@rogue.oti.com...
> yes, but RectangleFigure doesn't have such a method.. (Eclipse
200303272130
> WinXP)
>
> "Randy Hudson" <none@us.ibm.com> wrote in message
> news:bab415$hh0$1@rogue.oti.com...
> > Popup menus should be done by creating a Menu and setting it as the
> context
> > menu on a control. (setMenu(Menu))
> >
> > "Remo Laubacher" <laubi@nicely.ch> wrote in message
> > news:baatvt$c66$1@rogue.oti.com...
> > > hi!
> > >
> > > I've got the following code:
> > > RectangleFigure node1 = new RectangleFigure();
> > > node1.addMouseListener(new MouseListener.Stub() {
> > > public void mousePressed(MouseEvent event) {
> > > if (event.button == 3) {
> > > classMenu.setVisible(true);
> > > }
> > > }
> > > });
> > >
> > > classMenu = new Menu (shell, SWT.POP_UP);
> > > item = new MenuItem (classMenu, SWT.PUSH);
> > > item.setText ("Delete");
> > > classMenu.addListener (SWT.Show, new Listener () {
> > > public void handleEvent (Event event) {
> > > System.out.println("here we are..");
> > > }
> > > });
> > >
> > > this works well, but when the popup menu is shown I must know which
> > control
> > > was "active" (the object that the user has pushed..).. When I call a
> > > function (not implemented in the source code above) from the menu (as
an
> > > example "delete") I have to know which control I should remove...
What's
> > the
> > > best way to do this?
> > >
> > > thanks for any help!
> > >
> > > Remo
> > >
> > >
> > >
> >
> >
>
>
Re: popup menu on a figure [message #80127 is a reply to message #80099] Mon, 19 May 2003 17:03 Go to previous message
Eclipse UserFriend
Originally posted by: laubi.nicely.ch

I see, I was searching at the wrong place.. Thanks for your help!

"Randy Hudson" <none@us.ibm.com> wrote in message
news:babc2n$olu$1@rogue.oti.com...
> Neither does TreeItem. Figures are not meant to be lightweight versions
of
> SWT Controls. There is no short definition, but they are objects which
> layout, paint, and can be hit-tested.
>
> If you want to include the concept of selection, this is one thing that
GEF
> adds to draw2d. An EditPart is the unit of selection, and EditPartViewers
> maintain the set of selected editparts.
>
> "Remo Laubacher" <laubi@nicely.ch> wrote in message
> news:bab9iv$mcd$1@rogue.oti.com...
> > yes, but RectangleFigure doesn't have such a method.. (Eclipse
> 200303272130
> > WinXP)
> >
> > "Randy Hudson" <none@us.ibm.com> wrote in message
> > news:bab415$hh0$1@rogue.oti.com...
> > > Popup menus should be done by creating a Menu and setting it as the
> > context
> > > menu on a control. (setMenu(Menu))
> > >
> > > "Remo Laubacher" <laubi@nicely.ch> wrote in message
> > > news:baatvt$c66$1@rogue.oti.com...
> > > > hi!
> > > >
> > > > I've got the following code:
> > > > RectangleFigure node1 = new RectangleFigure();
> > > > node1.addMouseListener(new MouseListener.Stub() {
> > > > public void mousePressed(MouseEvent event) {
> > > > if (event.button == 3) {
> > > > classMenu.setVisible(true);
> > > > }
> > > > }
> > > > });
> > > >
> > > > classMenu = new Menu (shell, SWT.POP_UP);
> > > > item = new MenuItem (classMenu, SWT.PUSH);
> > > > item.setText ("Delete");
> > > > classMenu.addListener (SWT.Show, new Listener () {
> > > > public void handleEvent (Event event) {
> > > > System.out.println("here we are..");
> > > > }
> > > > });
> > > >
> > > > this works well, but when the popup menu is shown I must know which
> > > control
> > > > was "active" (the object that the user has pushed..).. When I call a
> > > > function (not implemented in the source code above) from the menu
(as
> an
> > > > example "delete") I have to know which control I should remove...
> What's
> > > the
> > > > best way to do this?
> > > >
> > > > thanks for any help!
> > > >
> > > > Remo
> > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
Previous Topic:moving an editpart
Next Topic:How to Lay out figures and reflect changes in the model?
Goto Forum:
  


Current Time: Tue Jul 22 00:54:15 EDT 2025

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

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

Back to the top