Hi Ernst;

Which version of ULC are you using? Kindly mention the version with your
posting.

I ran your sample with ULC 6.1.

In your sample, please remove the Action and Focus Listeners from the text
field. Instead, use a IValueChangedListener:

       textField1.addValueChangedListener(new IValueChangedListener() {
            public void valueChanged(ValueChangedEvent event) {
                System.out.println("ValueChanged of Text");
                bean.setText(textField1.getText());
            }

        });


Also, you must specify the default button and IActionListener on the button
(as you have already done):

   pane.getRootPane().setDefaultButton(button);


Now when you press Enter in the textfield after changing its text, first
ValueChangedEvent is fired for the textfield followed by ActionEvent on the
button.

I hope this helps.

Thanks and regards,

Janak

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Plüss Ernst, Bedag
Sent: Thursday, July 13, 2006 11:16 AM
To: [EMAIL PROTECTED]
Subject: [ULC-developer] Combining DefaultButton an ActionListener


Hi All
We have a GUI which consists of some ULCTextFields and an ULCButton. We'd
like to have the following functionality: If the enter key is hit, the
button must execute an action, based on the values of the text fields.
Well that's the users point of view. Technicaly the text fields are backed
by a data bean, each time something changes in a text field, the bean is
updated. Once the user hits return, the action of the ok button should take
the values of the data bean to execute it's action.
Unfortunately this doesn't work. If we add an action listener to the text
field in order to update the data bean, hitting enter updates the data bean,
but dos not push the default button anymore (as correcty stated in the
docs). We also tried updating the data bean via a focus listener or a
registered key stroke, but this doesn't work as well.
In short we need a way to have a action listener on a text field (or other
ULCComponents) which does not consume the action event, but leavs it for the
panel to execute the action on the default button. It's also very important,
that the order doesn't get mixed up, the default button must always be the
last action.
The attached snippet trys to make the things more clear. Please note that
this is just an example showing our problem. In reality the action of the
button has no possibility to access the text fields directly it has nothing
else than the data bean.
<<DefaultButtonSnippet.java>>
TIA
Ernst Plüss
Bedag Informatik AG
Abteilung GF GBA
Gutenbergstrasse 1
3012 Bern
Telefon:        +41 (0)31 633 21 21 (direkt 633 25 89)
E-Mail:         mailto:[EMAIL PROTECTED]
www.bedag.ch

_______________________________________________
ULC-developer mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/ulc-developer

Reply via email to