Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Window - programatically setCanDragResize => cannot select text in child

    Hello everyone,

    I have a weird (actually more, but let's not get hasty) behaviour of Window. I initialize the object with setCanDragResize(false) and setCanDragReposition(false).
    Code:
    window.setCanDragReposition(false);
    window.setCanDragResize(false);
    I add a VLayout object as item to this window:
    Code:
    window.addItem(createVLayout());
    The VLayout object holds an HTMLText pane (as first member):
    Code:
    final HTMLPane htmlPane = createHTMLPane();
    
    Canvas canvas = new Canvas();
    canvas.setWidth100();
    canvas.setHeight("70%");
    canvas.setShowResizeBar(true);
    canvas.addChild(conversationPane);
    
    VLayout vLayout = new VLayout();
    vLayout.setHeight100();
    vLayout.setWidth100();
    vLayout.setResizeBarTarget("next");
    // add widgets to layout
    vLayout.addMember(canvas);
    [...]
    The parent Window object has a HeaderControl button used to toggle between window (dragable & resizeable) / (not dragable & not resizeable) states
    Code:
            final HeaderControl pinControl = new HeaderControl(HeaderControl.PIN_DOWN);
            pinControl.setTooltip("toggle this button to be able to resize and drag this window");
            pinControl.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent event) {
                    if (pined[0]) {
                        window.setTitle("Chat (draggable)");
                        window.setCanDragReposition(true);
                        window.setCanDragResize(true);
                        window.setCanSelectText(true);
                        pinControl.setSrc("[SKIN]/headerIcons/pin_left.png");
                        pined[0] = false;
                    } else {
                        window.setTitle("Chat (pinned)");
                        window.setCanDragReposition(false);
                        window.setCanDragResize(false);
                        pinControl.setSrc("[SKIN]/headerIcons/pin_down.png");
                        pined[0] = true;
                    }
                }
            });
    The problem is that when I launch the app, I can select the text in the HTMLPane (window not dragable / resizeable); but when I press the header control button, the window becomes dragable and resizeable, BUT I CAN NO LONGER SELECT TEXT IN THE HTMLPane, because when I try to do that the window is being dragged. As I press the button again and make the window "pinned" (not dragable and not resizeable), I can select the text in the HTMLPane again.

    Can you please show me the right way I should implement this in order to work properly? I want to be able to select text in the HTMLPane even if the window's state was programatically set to canDragResize(true) and canDragReposition(true).

    Thanks!

    #2
    C'mon, people, there must be somebody that has an answer to this, right?!

    Comment


      #3
      Why not just cancel the drag event when it occurs within the html pane?

      Comment


        #4
        Thanks, svjard,

        But doing so will overcomplicate the code for nothing. If I have 3 html panes, I'll have to manage the Drag for all 3 of them... Or, the canDragResize is related to the window, not its content, right?

        Comment


          #5
          Well your problem doesn't make much sense. I mean take the Showcase example http://www.smartclient.com/smartgwt/showcase/#layout_windows_dragging. This is like yours correct? Well adding HTMLPane.setCanSelectText(true) I can select the text but no dragging occurs of the window. So what are you doing differently from that example?

          Comment


            #6
            I know my problem doesn't make sense. That's why I've posted the question.
            Yes, the showcase was my start point when I've implemented this. Actually, I'm constantly following the showcase.
            The difference is I programatically change the window's setCanDragResize state.
            Last edited by pansos; 19 Jul 2010, 10:45.

            Comment


              #7
              OK gotcha. This is a bug! Isomorphic I think either the docs need to state dynamically changing the drag state isn't supported after creation or need to change the code. Here is the workaround:
              Code:
              public class MyWindow extends Window {
                  	public native void switchDragState(boolean canDrag) /*-{
                  		var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()();
                  		self.header.canDragReposition = canDrag;
                  		self.header.dragTarget = self;
                  		self.canDragReposition = false;
                  	}-*/;
                  };
              Note use switchDragState() ONLY AFTER creation.
              Last edited by svjard; 19 Jul 2010, 15:40.

              Comment


                #8
                Thanks a lot, svjard!!!!!

                Comment

                Working...
                X