| Summary: | Shell.setSize within SWT.Resize listener not working | ||
|---|---|---|---|
| Product: | [RT] RAP | Reporter: | John Gymer <jgymer> |
| Component: | RWT | Assignee: | Project Inbox <rap-inbox> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | ivan |
| Version: | 3.4 | ||
| Target Milestone: | 3.5 M3 | ||
| Hardware: | PC | ||
| OS: | Windows 7 | ||
| See Also: |
https://git.eclipse.org/r/120994 https://git.eclipse.org/c/rap/org.eclipse.rap.git/commit/?id=90bb6675bddfc95b6859d086958c14f0348bc78f |
||
| Whiteboard: | |||
Hi John, I can confirm the issue. Yes, it's a bug, but I have to think a little bit more how to fix it. The re-set value is not rendered back from the server as from the server point of view the width stays changed. It was 100 before the request and it stays 100 after it. Ok, thanks Ivan! New Gerrit change created: https://git.eclipse.org/r/120994 Gerrit change https://git.eclipse.org/r/120994 was merged to [master]. Commit: http://git.eclipse.org/c/rap/org.eclipse.rap.git/commit/?id=90bb6675bddfc95b6859d086958c14f0348bc78f Looks good - I tested with the Nightly and seems to work now - thanks! Thanks for testing. |
I use a SWT.Resize listener on a resizeable shell where I wish to allow the user to resize the height, but reset the width to a predefined value. However, when I use shell.setSize inside the listener, it does not visually update the width correctly if only the width was dragged by the user. If the user drags the corner (thus changing the width AND height), then the setSize works correctly. Below is a snippet to show the behaviour. This is with RAP 3.4, but also appears to happen with older RAP releases too: <code> /* DEMONSTRATES shell resize and reset issue in RAP - resize just horizontally */ package bug.snippet; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; public class Bugsy { private Display display; private Shell shell; public void begin() { System.out.println("BugSnippy Starting..."); // create the Shell display = new Display(); shell = new Shell(display, SWT.TITLE|SWT.CLOSE|SWT.RESIZE); shell.setText("Shell"); shell.setBounds(20, 20, 100, 100); shell.setFullScreen(false); shell.setBackground(new Color(null, new RGB(255,192,128))); FormLayout layout = new FormLayout(); shell.setLayout(layout); shell.addListener(SWT.Resize, rzListener); shell.open(); System.out.println("BugSnippy Done!"); } Listener rzListener = new Listener() { @Override public void handleEvent(Event event) { switch (event.type) { case SWT.Resize: Point ptSz = shell.getSize(); System.out.println("Resize Event received: " + event + " sz=" + ptSz); if (ptSz.x != 100) { // resetting width to 100 - only works if height also changed in this event shell.setSize(100, ptSz.y); } break; } } }; } </code> To recreate, run the snippet and try to resize the corner first - this works OK - allows height change, but resets the width to 100 pixels. Then try resizing JUST the width using the right edge of the shell - the event is triggered OK, but it does not visually reset the shell's width to 100 until the next UI refresh. As far as I can tell, the shell is getting a new size, but the presentation of it onto the browser is not reflecting the change. Same behaviour for Chrome and IE. Does this look like a bug? Thanks, John