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

Reply via email to