|
|
|
|
|
|
Re: Listener for SashForm [message #441266 is a reply to message #441260] |
Thu, 12 August 2004 18:47 |
Christian Hauser Messages: 189 Registered: July 2009 |
Senior Member |
|
|
Thanx Devon. I'll check that tomorrow (we have 8:41 p.m. here). However,
I need more than just the weights. I also want the composite a in your
example to be always at least 210 pixel wide.
I did not figure out how to do that with SashForm. Using a Sash (with a
selection listener) would work, I guess, however, I don't see how to it
using SashForm. My current implementation works by resizing both
composite a and b and then set the weights of the SashForm... I'll
improve my solution tomorrow using a ControlListener.
Thanks.
Devon Berry wrote:
> Not elegant, but it will at least solve your problem: Add a control
> listener to the composites that are on your sash form and store the weights
> on the control resized event. Here's an example:
>
> public static void main(String[] args) {
> Display display = new Display();
> Shell shell = new Shell(display);
> shell.setLayout(new FillLayout());
>
> final SashForm sash = new SashForm(shell, SWT.VERTICAL);
>
> Composite a = new Composite(sash, SWT.NONE);
> a.setBackground(display.getSystemColor(SWT.COLOR_CYAN));
>
> Composite b = new Composite(sash, SWT.NONE);
> b.setBackground(display.getSystemColor(SWT.COLOR_RED));
>
> a.addControlListener(new ControlListener() {
> public void controlResized(ControlEvent e) {
> int[] weights = sash.getWeights();
> // Store your weights here
> System.out.println("Weights: " + weights[0] + " " + weights[1]);
> }
>
> public void controlMoved(ControlEvent e) {
> }
> });
>
> shell.open();
> while (!shell.isDisposed()) {
> if (!display.readAndDispatch())
> display.sleep();
> }
> display.dispose();
> }
>
> Devon
>
> "Christian Hauser" <christian.hauser@dvbern.ch> wrote in message
> news:cffv4j$pk6$1@eclipse.org...
>
>>Hello all
>>
>>I'm using org.eclipse.swt.custom.SashForm and would like to know how I
>>get informed when the sash is moved.
>>
>>No matter what listener I add to SashForm (Control, Resize), I do not
>>get notified when I resize the sash.
>>
>>I use such functionality to store the weights of the components of the
>>SashForm in a properties file. So that I can call SashForm#setWeights
>>the next time the application starts and the sash form looks the way the
>>user likes it.
>>
>>Any hint on that is highly appreciated.
>>
>>Thanks in advance,
>> Christian
>
>
>
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04130 seconds