user468587
user468587

Reputation: 5031

gwt dialogbox won't move

i created a dialog box using uiBinder in gwt app, it works fine except it cannot move around. i don't know what's wrong with it, do i have to set caption in order to move it around?

here is my code: myDialog.ui.xml

  <g:HTMLPanel ui:field="_glossaryPanel">
   <div class="dialogBox">
     <h3>content goes here..</h3>
     <p>More content...</p>
   </div>
  </g:HTMLPanel>

myDialog.java

public class MyDialog extends DialogBox {

private static MyDialogUiBinder uiBinder = GWT.create(MyDialogUiBinder.class);

interface MyDialogUiBinder extends UiBinder<Widget, MyDialog> {
}

public MyDialog() {
    setWidget(uiBinder.createAndBindUi(this));
    this.setModal(true);
    this.setAutoHideEnabled(true);
}

FooterView.java

public class FooterView extends Composite implements FooterPresenter.Display {

    interface Binder extends UiBinder<Widget, FooterView> {
    }
    private static final Binder BINDER = GWT.create(Binder.class);

    @UiField
    Anchor _glossary;

    @UiHandler("_glossary")
    public void handleGlossaryClick(ClickEvent event) {
        MyDialog mDialog = new MyDialog();
        mDialog.setGlassEnabled(true);
        mDialog.setAnimationEnabled(true);
        mDialog.center();
        mDialog.show();
    }

Upvotes: 1

Views: 1701

Answers (5)

Galin G
Galin G

Reputation: 1

"do i have to set caption in order to move it around?" Yes.

dialogbox.setText("DialogBox"); You may drag only catpion div; When you drag caption div, whole dialog box will move.

Upvotes: 0

z00bs
z00bs

Reputation: 7498

See http://gwt.google.com/samples/Showcase/Showcase.html#!CwDialogBox You have to use a DialogBox (not a PopupPanel) to move the thing around.

EDIT:

I tried your code and it worked for me. Have you tried clicking in the border (not content!) to drag the dialog box around?

Upvotes: 3

Vijay Sarin
Vijay Sarin

Reputation: 1336

Here is the Solution,

VerticalPanel panel;
DialogBox dialogbox;
PopupPanel glass;
VerticalPanel DialogBoxContents;
ClickListener listener;
HTML message;
Button button;
SimplePanel holder;

public void demo()
{
    // Create a panel and add it to the screen
    panel = new VerticalPanel();
    RootPanel.get("demo").add(panel);
    panel.setStyleName("table-center");
    //
    // Create a DialogBox with a button to close it
    dialogbox = new DialogBox(false);
    dialogbox.setStyleName("demo-DialogBox");
    DialogBoxContents = new VerticalPanel();
    dialogbox.setText("DialogBox");
    message = new HTML("Click 'Close' to close");
    message.setStyleName("demo-DialogBox-message");
    listener = new ClickListener()
    {
        public void onClick(Widget sender)
        {
            dialogbox.hide();
        }
    };
    button = new Button("Close", listener);
    holder = new SimplePanel();
    holder.add(button);
    holder.setStyleName("demo-DialogBox-footer");
    DialogBoxContents.add(message);
    DialogBoxContents.add(holder);
    dialogbox.setWidget(DialogBoxContents);
    //
    // Add a button to the demo to show the above DialogBox
    listener = new ClickListener()
    {
        public void onClick(Widget sender)
        {
            dialogbox.center();
        }
    };
    button = new Button("Show DialogBox", listener);
    panel.add(button);
}

Check out the DEMO AT http://examples.roughian.com/index.htm#Widgets~DialogBox

Upvotes: 0

Overnuts
Overnuts

Reputation: 803

Maybe you could try in your ui.xml file to change the root element type

from HTMLpanel to a FlowPanel

I saw somewhere that was saying something like this. where ? I can't remember :-(

your <div clas="dialogBox"> is, in my opinion, a bit confusing, maybe yould consider renaming to something more personal and less in gwt keywords' like.

Upvotes: 0

Deanna
Deanna

Reputation: 696

GWT Dialogs can't be moved around like a desktop window. There was a projected called gwt-windows that would let you do that, but it hasn't been updated in years.

Upvotes: 0

Related Questions