Sunday, July 20, 2014

Re: SplitLayoutPanel - unable to move splitters



On Sunday, July 20, 2014 12:11:22 AM UTC+2, Magnus wrote:
Hi,

I am creating a layout with a SplitLayoutPanel:


But when I try to drag a splitter, it does not work. I can click and hold the mouse button, but the splitter does not move.

What can I do?
(see code below)

Thanks
Magnus

---

package mcs.client.div.main.pnl;

import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.SplitLayoutPanel;

public class MasterPanel extends SplitLayoutPanel
{

Unrelated to your problem but you shouldn't extend SplitLayoutPanel.
Use a ResizeComposite wrapping a SplitLayoutPanel instead (or possibly just implement HasWidget).
 
 private SplitLayoutPanel pnl_n = new SplitLayoutPanel ();
 private SplitLayoutPanel pnl_c = new SplitLayoutPanel ();
 private SplitLayoutPanel pnl_s = new SplitLayoutPanel ();
 
 public MasterPanel ()
 {
  super ();
  init ();
 }

 private void init ()
 {
  pnl_n.add (new HTML ("North"));
  pnl_c.add (new HTML ("Center"));
  pnl_s.add (new HTML ("South"));
  
  addNorth (pnl_n,100);
  addSouth (pnl_s,100);
  add (pnl_c);
 }

 @Override
 public void onResize ()
 {
  super.onResize ();

  int xs = getOffsetWidth ();
  int ys = getOffsetHeight ();
  int pys = (int) (ys * 0.25);
  
  setWidgetSize (pnl_n,pys);
  setWidgetSize (pnl_s,pys);
  
  pnl_n.setVisible (true);
  pnl_c.setVisible (true);
  pnl_s.setVisible (true);
 }
 
}




Every time you try to move the splitters, your onResize fires and forcefully resizes the widgets to take 25%, 50% and 25% of the available space respectively. So nothing actually resizes.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment