Missing cursor in dialogs

3 views
Skip to first unread message

Anders

unread,
Sep 28, 2007, 6:30:52 AM9/28/07
to Google Web Toolkit

I have a problem with dialogs in Google Web Toolkit. When a create a
Dialog with a TextBox inside it, the TextBox does not show a blinking
cursor even when the TextBox is active. This makes it difficult for
the user to edit the text. (Editing works fine, but is difficult since
the user can't see where the cursor is.)

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

Peter Blazejewicz

unread,
Sep 28, 2007, 6:45:31 PM9/28/07
to Google Web Toolkit
hi Anders,
do you have a link to relevant mozilla bugzilla thread or something?
maybe poeple from GWT contrib list could apply fix if exists,
regards,
Peter

Anders

unread,
Sep 29, 2007, 9:38:36 AM9/29/07
to Google Web Toolkit
This link tells me that there is a problem with disappearing text
cursors:

https://bugzilla.mozilla.org/show_bug.cgi?id=167801

Anders

Reinier Zwitserloot

unread,
Sep 29, 2007, 12:56:56 PM9/29/07
to Google Web Toolkit
It's a bug in FireFox and has nothing to do with GWT. Easiest
workaround is to put a <div styke="position: fixed;"> around the
textbox. In GWT speak that would be a SimplePanel with a certain type.

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.

darkman97

unread,
Sep 29, 2007, 2:11:31 PM9/29/07
to Google Web Toolkit
The most easy way to solve this firefox bug, is to put the TextBox
into a ScrollPanel, without direct access to DOM.

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 ! ).

Reply all
Reply to author
Forward
0 new messages