Here is the patch

Best regards...


Sebastian Werner schrieb:
Dietrich Streifert schrieb:
OK I had a look through the sources and got (hopefully) the place where the focus is set. It is in QxWidget.js:

proto._visualizeFocus = function()
{
 if (!QxFocusManager.mouseFocus && this.getEnableElementFocus())
 {
   try {
     this.getElement().focus();
   } catch(ex) {};
 };

 this.setFocusState(QxConst.STATE_FOCUSED);
 return true;
};

In symetry to the proto._visualizeBlur method I modified the condition in the if statement to:

 if (this.getEnableElementFocus())

And it does the trick! Yes! The focus appears as expected!

Ok, yes. But this is not the way to go.

QxFocusManager.mouseFocus is needed to omit a focus() call if you are working with the mouse currently. We probably should change this in QxTextField (overwrite) directly. Could you submit a patch?

Sebastian





Sebastian Werner schrieb:
Dietrich Streifert schrieb:
I modified the Window_4 example in two ways:

1) the first text field has an event listener "beforeAppear" which sets the focus to the field via setFocused(true). 2) the "Set Focus To First Field" button has an execute event listener which sets the focus to the field via setFocused(true)

Both have no effect. This is for FireFox 1.5 and IE 6.

OK, I meant "appear", not "afterAppear". You can't use "beforeAppear", because then the widget is not already available in DOM.

I have currently no idea, how to fix this. Will probably not be fixed with the next release. A timeout started with the appear event could probably help.

Sebastian



I think this is really a bug.

Testcase is attached.

Sebastian Werner schrieb:
Dietrich Streifert schrieb:
Hello List,

after all these changes to the event manager and the introduction of the appearance stuff I've reached again the point where I want to set the cursor into a QxTextField programatically.

The situation is as follows: I have a QxTextField in a QxWindow. When the user does an action which displays the window, the cursor should be positioned automatically to the first text field. This is the behaviour I would normally expect in a modal dialog.

Calling the setFocused(true) method on the text field does not seem to have any effect. Please have a look at the Window_4 example.

I had a working (but ugly) code which seemed to do the trick but after all these changes It doesn't work anymore in FireFox. With this the caret was set to the end of the text in the text field.

proto._setCaretToEnd = function (control) {
 if (control.createTextRange) {
   var range = control.createTextRange();
   range.collapse(false);
   range.select();
 }
 else if (control.setSelectionRange) {
   control.focus();
   var length = control.value.length;
   control.setSelectionRange(length, length);
 }
};


proto._setCaretToStart = function(control) {
 if (control.createTextRange) {
   var range = control.createTextRange();
   range.collapse(true);
   range.select();
 }
 else if (control.setSelectionRange) {
   control.focus();
   control.setSelectionRange(0, 0);
 }
};


proto._setFocus = function() {
 try {
   var el = this.getElement();
   this._setCaretToEnd(el);
   this.setFocused(true);
 }
 catch(err) {};
};


How can this be done? Is there a clean qooxdoo way of setting the focus?

Thank you for your help.

You can normally use the setFocused(true) which is IMHO the best way. One simple thing you must understand is, that a focus work only for visible elements in qooxdoo and html. That means you can attach a afterAppear event to the textField and try to setFocused(true) there. I haven't already tried this before. Just an first idea.

Sebastian



Best regards.




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel


------------------------------------------------------------------------

Dialog with QxForm and QxTextArea

Testing initial focus handling.




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

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

*** source/script/widgets/QxTextField.js.orig   Wed Feb  1 20:55:23 2006
--- source/script/widgets/QxTextField.js        Wed Feb  1 20:55:36 2006
***************
*** 482,490 ****
--- 482,507 ----
  
  
  
+ /*
+ ---------------------------------------------------------------------------
+   FOCUS HANDLING
+ ---------------------------------------------------------------------------
+ */
  
+ proto._visualizeFocus = function()
+ {
+   if (this.getEnableElementFocus())
+   {
+     try {
+       this.getElement().focus();
+     } catch(ex) {};
+   };
  
+   this.setFocusState(QxConst.STATE_FOCUSED);
+   return true;
+ };
  
+ 
  
  /*
  ---------------------------------------------------------------------------

Reply via email to