My widget extends Composite and I have implemented
SourcesMouseEvents. In the class where I define the panel that will
contain the widgets, I've added the DragController and a
GridConstrainedDropController. From what I can see based on examples,
I've done everything correctly.
However, when I add a widget, I cannot move it. I'm not sure what I'm
doing wrong. I did test it with a simple Label and it works so I
think there may be an issue with the fact that I'm trying to move a
custom widget.
public void addRuleGraphics(GraphicImage image)
{
dragController.makeDraggable(image);
dropController.drop(image, 0, 0);
}
public class GraphicImage extends Composite implements
SourcesMouseEvents
{
private Image image;
private Label label;
private AbsolutePanel imagePanel = new AbsolutePanel();
private MouseListenerCollection mouseListenerCollection;
public GraphicImage(String url, String text)
{
image = new Image(url);
label = new Label(text);
label.setStyleName("gui-GraphicLabel");
label.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
label.setPixelSize(70, 70);
imagePanel.setPixelSize(100, 100);
imagePanel.add(image);
imagePanel.add(label, 0, 0);
initWidget(imagePanel);
}
public void addMouseListener(MouseListener listener)
{
if (mouseListenerCollection == null)
{
mouseListenerCollection = new MouseListenerCollection();
}
mouseListenerCollection.add(listener);
}
public void removeMouseListener(MouseListener listener)
{
if (mouseListenerCollection != null)
{
mouseListenerCollection.remove(listener);
}
}
}
> mouseListeners.fireMouseEvent (this, event);
> > label.setStyleName ("gui-GraphicLabel");
>
> > label.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
> > label.setPixelSize(70, 70);
>
> > imagePanel.setPixelSize(100, 100);
> > imagePanel.add (image);
> > imagePanel.add(label, 0, 0);
>
> > initWidget(imagePanel);
> > }
>
> > public void addMouseListener(MouseListener listener)
> > {
> > if (mouseListenerCollection == null)
> > {
> > mouseListenerCollection = new MouseListenerCollection();
> > }
>
> > mouseListenerCollection.add (listener);
> > }
>
> > public void removeMouseListener(MouseListener listener)
> > {
> > if (mouseListenerCollection != null)
> > {
> > mouseListenerCollection.remove(listener);
> > }
> > }
> > }
>
> --
> Fred Sauer
> f...@allen-sauer.com
http://blogs.nubgames.com/code/?p=9
And then near the end (in the "Wait! It gets even easier" section),
says to wrap your widget up in a FocusPanel and you're done.
-- bosco
On Mar 9, 2:35 pm, "Fred Sauer" <f...@allen-sauer.com> wrote:
> rBehrens,
>
> Using Composite is indeed very tricky. You'll using other panels easier. If
> you must use Composite in its current incarnation, you might glance at this
> thread:
>
> http://groups.google.com/group/Google-Web-Toolkit/browse_thread/threa...
>
> Fred
> > > > label.setStyleName("gui-GraphicLabel");
>
> > > > label.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
> > > > label.setPixelSize(70, 70);
>
> > > > imagePanel.setPixelSize(100, 100);
> > > > imagePanel.add (image);
> > > > imagePanel.add(label, 0, 0);
>
> > > > initWidget(imagePanel);
> > > > }
>
> > > > public void addMouseListener(MouseListener listener)
> > > > {
> > > > if (mouseListenerCollection == null)
> > > > {
> > > > mouseListenerCollection = new MouseListenerCollection();
> > > > }
>
> > > > mouseListenerCollection.add (listener);
> > > > }
>
> > > > public void removeMouseListener(MouseListener listener)
> > > > {
> > > > if (mouseListenerCollection != null)
> > > > {
> > > > mouseListenerCollection.remove(listener);
> > > > }
> > > > }
> > > > }
>
> > > --
> > > Fred Sauer
> > > f...@allen-sauer.com
>
> --
> Fred Sauer
> f...@allen-sauer.com- Hide quoted text -
>
> - Show quoted text -