This problem seems to appear only in Firefox (2.0.0.7). The cursor is
visible in IE.
I have searched for an answer both in this forum and in general, and
this behaviour seems to be a known bug in Firefox which has to do with
Firefox and JavaScript in general.
However, I have not been able to discover a workaround to this bug in
GWT. Anyone?
Anders
https://bugzilla.mozilla.org/show_bug.cgi?id=167801
Anders
I recall that the latest FF versions no longer have this X-year old
bug.
Here, have my code for this:
package to.tipit.gwtlib.ui;
import to.tipit.gwtlib.ExtDOM;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.TextBoxBase;
import com.google.gwt.user.client.ui.Widget;
/**
* For some reason a bug has existed since the first versions of
firefox all the way up to late versions of firefox 2:
* TextBoxes have no cursor when absolutely positioned.
*
* This class contains utility methods to optionally wrap them to work
around the bug. These methods check if firefox is the browser
* and in that case work around the issue.
*/
public class CursorTextBox {
public static void addTextBox(Panel x, TextBoxBase textBox) {
x.add(wrapTextBox(textBox));
}
public static Widget wrapTextBox(TextBoxBase textBox) {
if ( ExtDOM.getUserAgent().equals("gecko") ) {
SimplePanel wrapPanel = new SimplePanel();
DOM.setStyleAttribute(wrapPanel.getElement(), "overflow", "auto");
wrapPanel.setWidget(textBox);
return wrapPanel;
} else return textBox;
}
}
and getUserAgent looks like this:
/** returns 'opera', 'safari', 'ie6', 'ie7', 'gecko', or 'unknown'.
*/
public static native String getUserAgent() /*-{
try {
if ( window.opera ) return 'opera';
var ua = navigator.userAgent.toLowerCase();
if ( ua.indexOf('webkit' ) != -1 ) return 'safari';
if ( ua.indexOf('msie 6.0') != -1 ) return 'ie6';
if ( ua.indexOf('msie 7.0') != -1 ) return 'ie7';
if ( ua.indexOf('gecko') != -1 ) return 'gecko';
return 'unknown';
} catch ( e ) { return 'unknown' }
}-*/;
which is something I really need to be fixing to just leech off of
GWT's own much better browser detector, but, for now.
Really it's not pleasant solution, but in some cases it could be
interesting ( particulary us, we don't like too much changing original
elements accessing DOM, how be affected our application on future GWT
upgrades, but sometimes is needed ! ).