View Full Version : [1.2.3] Can't constrain window with container
The_Jackal
22 Mar 2009, 9:59 PM
Hi,
The following code won't constrain a window within a container.
I have seen examples using ExtJS, so either my code is wrong, there's a bug, or GXT can't do this yet.
If there is another way to do this, please guide me in the right direction.
public void onModuleLoad()
{
ContentPanel center = new ContentPanel();
center.add(new Html("Center"));
center.setSize(400, 400);
ContentPanel west = new ContentPanel();
west.add(new Html("West"));
west.setSize(100, 400);
HorizontalPanel main = new HorizontalPanel();
main.add(west);
main.add(center);
Window w = new Window();
w.setSize(200, 200);
w.setConstrain(true);
w.setContainer(center.getElement());
w.show();
}
Regards,
The Jackal
The container is only for maximazing the window. Not for dragging.
The_Jackal
27 Mar 2009, 3:29 AM
Hi,
I've see this done in ExtJS - for example in Saki's http://examples.extjs.eu
The panel/window -> Simple Window/Panel auto load example the window is limited to the center panel (see pic).
Can this be done in GXT?
Regards,
Carl.
EXTJs is not exactly the same than GXT. I move this into the help forum.
I look into adding this for the GXT2.0 release.
The_Jackal
27 Mar 2009, 3:38 AM
Thanks Sven.
takayser
30 Mar 2009, 12:49 AM
+1
francescoNemesi
31 Mar 2009, 1:48 AM
I do this already with GXT 1.2.3 with the following code
Draggable draggable = getDraggable();
draggable.setContainer(container);
where container is the Component that you want to use as container.
Hope this helps
Yes draggable already has this.
The_Jackal
6 Apr 2009, 11:47 PM
Well those hints have a mostly working solution - I can constrain the title of the window (it's "draggable") to a container... which effectively means a window is contained in a center panel in every direction but south.
The code I used is
private class ConstrainedWindow extends Window {
private Container constrainContainer = null;
public void setConstrainContainer(Container<Component> constrainContainer)
{
this.constrainContainer = constrainContainer;
}
@Override
protected void afterRender()
{
super.afterRender();
Draggable d = getDraggable();
d.setContainer(constrainContainer);
}
};
Usage:
ConstrainedWindow w = new ConstrainedWindow();
w.setConstrainContainer(myContainer);
takayser
7 Apr 2009, 12:24 AM
:D Cool, works great. Thank you!
...but as it is still a workaround, I hope this is on the todo list for GXT 2.0! :">
The_Jackal
7 Apr 2009, 5:58 PM
There is a better way that works in all directions.
Notes:
- The window may open outside the container so you need to control the opening position.
- The window position is relative to the browser
E.g. if you collapse a west panel and there are windows in a center panel then the windows won't move and can be rendered out of the constraining container
Sven - I think this should be how the window's draggable should be in the code base (rather than just the window's title bar) - your thoughts?
private class ConstrainedWindow extends Window {
private Container constrainContainer = null;
ConstrainedWindow(Container<Component> constrainContainer)
{
this.constrainContainer = constrainContainer;
}
@Override
protected void afterRender()
{
super.afterRender();
// Disable existing draggable adding one for whole window using existing handle
getDraggable().setEnabled(false);
Draggable d = new Draggable(this, getDraggable().getDragHandle());
d.setContainer(constrainContainer);
}
};Usage:
ConstrainedWindow w = new ConstrainedWindow(constrainContainer);
sjzaluk
14 May 2009, 10:11 AM
Has this been implemented in 2.0 M1? I can't seem to get it to work yet without this workaround. I thought Window.setConstrain(true) would do it but it's still not working for me.
Thanks,
Steve
xalvaro
24 Jul 2009, 7:24 AM
+1
:-?
in 2.0 ?
Especially for the Desktop in order to have the taskbar always on top
ApacheLogs
12 Aug 2009, 4:36 AM
i have a problem in migration to 3.0
i have occured many problems in migration to 3.0.there's any one who have migrate desktop whith success ??
mystix
12 Aug 2009, 7:04 AM
i have a problem in migration to 3.0
i have occured many problems in migration to 3.0.there's any one who have migrate desktop whith success ??
fyi, this is the GXT forum.
Powered by vBulletin® Version 4.1.5 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.