Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] Focus Out Problem

So many replies...


----- Original Message Follows -----
From: "z_hossain@xxxxxxxxxx" <z_hossain@xxxxxxxxxx>
To: platform-swt-dev@xxxxxxxxxxx
Subject: [platform-swt-dev] Focus Out Problem
Date: Tue, 10 Feb 2009 23:27:58 -0800

> How do I receive the Focus out event for all the widgets
> in an application for SWT GTK?
> It is possible in SWT Win32. Thanks in advance.
> 
> public class FocusTest {
> 
> public static void main (String [] args) {
>     Display display = new Display ();
>     Shell shell = new Shell (display);
>     Label label = new Label (shell, SWT.NONE);
>     label.setText ("Enter your name:");
>     Text text = new Text (shell, SWT.BORDER);
>     text.setLayoutData (new RowData (100, SWT.DEFAULT));
>     Button ok = new Button (shell, SWT.PUSH);
>     ok.setText ("OK");
>     ok.addSelectionListener(new SelectionAdapter() {
>         public void widgetSelected(SelectionEvent e) {
>             System.out.println("OK");
>         }
>     });
>     Button cancel = new Button (shell, SWT.PUSH);
>     cancel.setText ("Cancel");
>     cancel.addSelectionListener(new SelectionAdapter() {
>         public void widgetSelected(SelectionEvent e) {
>             System.out.println("Cancel");
>         }
>     });
>     display.addFilter(SWT.FocusIn, new Listener() {
>         @Override
>         public void handleEvent(Event event) {
>             System.out.println("Focus In");
>         }
>         
>     });
>     display.addListener(SWT.FocusOut, new Listener() {
>         @Override
>         public void handleEvent(Event event) {
>             System.out.println("Focus Out"); //Never
> printed
>         }
>     });
>     shell.setDefaultButton (cancel);
>     shell.setLayout (new RowLayout ());
>     shell.pack ();
>     shell.open ();
>     while (!shell.isDisposed ()) {
>         if (!display.readAndDispatch ()) display.sleep ();
>     }
>     display.dispose ();
> }
> }
> 
> _______________________________________________
> platform-swt-dev mailing list
> platform-swt-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/platform-swt-dev 


Back to the top