Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Clickable in a Draw2D figure
Clickable in a Draw2D figure [message #179620] Fri, 29 April 2005 01:27 Go to next message
Eclipse UserFriend
Originally posted by: nipun.walia.gmail.com

hi,
I have a draw2d figure called RectangularFigure that I want to put a
button into.
I want to be able to click the button (with some feedback) and change my
model in some way.

I added a draw2d button to my figure. Now the whole figure acts like a
flat image. Do I need to create a separate edit part/model class for the
button, to be able to click it independent of RectangularFigure and its
selection etc.

Is there a way I can click it without creating a separate editpart and
model ? How do I create a new Request that is then sent to my
RectangularEditPart so it creates a command. Can I get the selectionTool
to create my request or I have to create a tool also ?
I dont want the figure itself to create the command as it doesnt know
about the model etc.

thanks a lot,
let me know if I am way off..
Nipun
Re: Clickable in a Draw2D figure [message #179712 is a reply to message #179620] Fri, 29 April 2005 15:43 Go to previous message
Andreas Holtz is currently offline Andreas HoltzFriend
Messages: 53
Registered: July 2009
Member
Hi,

try to use a toogle button, add a actionListener to it, whose
actionPerfomed-method creates your command.

ExampleCode:

in the EditPart:

ActionListener itsButtonListener = new ActionListener(){
public void actionPerformed(ActionEvent event) {
handleActionPerformed(event);
}};

protected IFigure createFigure() {
Figure itsFigure = new FooFigure();
itsFigure.addButtonListener(itsButtonListener);
return itsFigure;
}

void handleActionPerformed(ActionEvent event){
// setSelected(true/false) the button and create your command
}

in the FooFigure:

public void addBouttonListener(ActionListener listener) {
itsButton.addActionListener(listener);
}


I hope this helps.

Andreas
Previous Topic:Changing the size of scrollbar
Next Topic:Cannot select/move/resize EditParts directly
Goto Forum:
  


Current Time: Tue Apr 23 09:05:55 GMT 2024

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

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

Back to the top