[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.platform.swt] Re: JComboBox event not fired in SWT
|
No luck? It feels to me that there is still some event forwarding
issues between SWT and Swing (a few I could name is tooltip, mouse
cursor doesn't change to "resize" cursor when hover between table column
headers)
Raccoonwao wrote:
> Hi, everybody!
>
> I got a JComboBox in SWT (JComboBox > JPanel > EmbeddedSwingComposite >
> Composite)
>
> I add the listeners as follows:
>
> ((JTextField)cmb.getEditor().getEditorComponent()).addKeyListener(new
> KeyListener() { ... }
>
> ((JTextField)cmb.getEditor().getEditorComponent()).getDocument().addDocumentListener(new
> DocumentListener() { ... }
>
> cmb.addActionListener(new ActionListener() { ... }
>
>
> Only ActionListener responses. The other two are just likely to be
> totally disappeared.
>
> The identical code is placed in a Swing-only application works
> perfect(i.e., I got all three kinds of events)
>
>
>
> I google for some time and find this from SwingWT doc. No sure if it is
> very relevant.
>
> protected void handleComboKeyStrokes()
>
> This routine will add the key handlers necessary for searching
> through combos by the key pressed (as Windows does, and as Swing does).
> This code really isn't too pretty, as SWT deactivates the key events if
> SWT.READ_ONLY is specified, so I have to handle that too, also you can't
> consume KeyEvents under a Combo (must be a bug), so I use a timer over
> the event pump to reset values. As I say, it's dirty but it works.
>
> Quoted from
> http://swingwt.sourceforge.net/javadoc/swingwtx/swing/JComboBox.html
>
>
> Thanks for any bit help!!!
>
> Trevor Leung
>