Hi Nick,

Nick Glencross schrieb:
[EMAIL PROTECTED] wrote:
"Nick Glencross" <[EMAIL PROTECTED]> writes:
  * I haven't successfully worked out how to make Enter in a form
submit it. There's a previous posting which shows how to do it by
sending the keypress event onto the submit button, but things must
have changed because the value of the text field that you are in
doesn't get correctly picked up. I can provide a test case to
demonstrate this if it helps.
Have you tried using qx.client.Command() for this purpose?  I think it should
be appropriate.

That's certainly more elegant than what I had, so I'll definitely be using it. However, it seems to suffer from the same problem that the current text field doesn't provide the correct value (due to some some caching which probably only updates when you leave the field).

I hoped that calling blur on the fields might help, but unfortunately not.
I've used the following code for a keydown and keyup event listeners with succes to enable "default" button activation on "enter" within a qx.ui.window.Window. Hitting the enter key should be forwarded to the OK button except the case the current focus is within a textarea.

The excerpt from this is that in the keydown listener first set the focus to the button (by calling setFocused(true)) and then reuse the event by calling dispatchEvent(event). The call to setFocused should move the focus away from the text field so the value gets propagated to "value" property of the text field. After this the listener to the buttons "execute" event is able to retreive the value of the text field. This should work if the text field is a qx.ui.form.TextField instance.

This method also gives a visual feedback to the user because the button changes to the pressed state and back.

Hope this helps. Here is the code:


qx.Proto._onKeydown = function(event) {
 var keyident = event.getKeyIdentifier();

 if( keyident=="Enter"){
   var target = event.getTarget();
   if(!(target instanceof qx.ui.form.TextArea)) {
     event.stopPropagation();
     event.preventDefault();
     this.getOkButton().setFocused(true);
     this.getOkButton().dispatchEvent(event);
   }
 }
};

qx.Proto._onKeyup = function(event) {
 var keyident = event.getKeyIdentifier();

 if( keyident=="Enter"){
   var target = event.getTarget();
   if(!(target instanceof qx.ui.form.TextArea)) {
     event.stopPropagation();
     event.preventDefault();
     this.getOkButton().dispatchEvent(event);
   }
 }
};


--
Mit freundlichen Grüßen
Dietrich Streifert
Visionet GmbH

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to