Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Shell.setSize within SWT.Resize listener not working(Shell.setSize not working if only 1 dimension changed)
Shell.setSize within SWT.Resize listener not working [message #1785110] Mon, 09 April 2018 15:03 Go to next message
John Gymer is currently offline John GymerFriend
Messages: 257
Registered: November 2012
Location: UK
Senior Member
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:

/* 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;
			}
		}
	};

}


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



---
Just because you can doesn't mean you should
Re: Shell.setSize within SWT.Resize listener not working [message #1785165 is a reply to message #1785110] Tue, 10 April 2018 08:18 Go to previous message
John Gymer is currently offline John GymerFriend
Messages: 257
Registered: November 2012
Location: UK
Senior Member
Raised bug:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=533412


---
Just because you can doesn't mean you should
Previous Topic:[SOLVED] Nebula GridTableViewer: how to update the inputs?
Next Topic:UI is blank after loosing connection for some time
Goto Forum:
  


Current Time: Mon Nov 19 03:53:04 GMT 2018

Powered by FUDForum. Page generated in 0.02221 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top