How to prevent resize event to pass to a child [message #540182] |
Tue, 15 June 2010 06:02  |
Eclipse User |
|
|
|
Hi,
I have an SWT (RCP) application.
I embed a native window into the widget hierarchy (win32):
// Remove window decoration
embedComp = new Composite(parent, SWT.EMBEDDED);
OS.SetParent(winHandle, embedComp.handle);
Since the embedded native window is heavyweight, I do not want it to be resized as the user drags the border of the SWT Shell (only when the user finally releases the mouse button).
I tried to filter the Resize events on the embedding Composite, but did not help:
display.addFilter(SWT.Resize, new Listener() {
@Override
public void handleEvent(final Event event) {
if (embedComp == event.widget) {
event.doit = false;
event.type = SWT.None;
}
}
}); The native window still gets resized as the user drags the Shell border.
Please let me know if you have any suggestion.
Thanks,
Marton
|
|
|
|
|
Re: How to prevent resize event to pass to a child [message #540290 is a reply to message #540188] |
Tue, 15 June 2010 10:32  |
Eclipse User |
|
|
|
Thanks for the idea, I could use it successfully.
I created a custom Layout, and a shell control listener within it.
When a resize event came in, I set a flag to forbid the layout() method to change anything:
public class MyLayout extends Layout {
public MyLayout(final Composite composite) {
final Shell shell = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getShell();
final ControlListener ctrlListener = new ControlAdapter() {
@Override
public void controlResized(final ControlEvent event) {
resizeForbidden = true;
scheduleDoLayout(DO_LAYOUT_DELAY);
}
};
shell.addControlListener(ctrlListener);
composite.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
shell.removeControlListener(ctrlListener);
}
});
}
@Override
protected void layout(final Composite composite, final boolean flushCache) {
if (resizeForbidden) {
return;
}
When no more resize events came for 2 secs, I reset the flag, and invoke the composite's layout() method.
Thanks again!
Marton
|
|
|
Powered by
FUDForum. Page generated in 0.14805 seconds