Revision: 7417
Author: [email protected]
Date: Fri Jan 15 13:48:32 2010
Log: tr...@7390 was merged into this branch
Refactor of FocusImpl.
svn merge --ignore-ancestry -c 7390
http://google-web-toolkit.googlecode.com/svn/trunk .
http://code.google.com/p/google-web-toolkit/source/detail?r=7417
Added:
/releases/2.0/user/src/com/google/gwt/user/client/ui/impl/FocusImplStandard.java
Deleted:
/releases/2.0/user/src/com/google/gwt/user/client/ui/impl/FocusImplOld.java
Modified:
/releases/2.0/branch-info.txt
/releases/2.0/user/src/com/google/gwt/dom/client/AnchorElement.java
/releases/2.0/user/src/com/google/gwt/dom/client/AreaElement.java
/releases/2.0/user/src/com/google/gwt/dom/client/ButtonElement.java
/releases/2.0/user/src/com/google/gwt/dom/client/Element.java
/releases/2.0/user/src/com/google/gwt/dom/client/InputElement.java
/releases/2.0/user/src/com/google/gwt/dom/client/ObjectElement.java
/releases/2.0/user/src/com/google/gwt/dom/client/SelectElement.java
/releases/2.0/user/src/com/google/gwt/dom/client/TextAreaElement.java
/releases/2.0/user/src/com/google/gwt/user/Focus.gwt.xml
/releases/2.0/user/src/com/google/gwt/user/client/ui/impl/FocusImpl.java
/releases/2.0/user/src/com/google/gwt/user/client/ui/impl/FocusImplSafari.java
=======================================
--- /dev/null
+++
/releases/2.0/user/src/com/google/gwt/user/client/ui/impl/FocusImplStandard.java
Fri Jan 15 13:48:32 2010
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
not
+ * use this file except in compliance with the License. You may obtain a
copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
under
+ * the License.
+ */
+package com.google.gwt.user.client.ui.impl;
+
+import com.google.gwt.core.client.JavaScriptObject;
+import com.google.gwt.user.client.Element;
+
+/**
+ * Implementation of {...@link com.google.gwt.user.client.ui.impl.FocusImpl}
that
+ * uses a hidden input element to serve as a 'proxy' for accesskeys, which
are
+ * only supported on form elements in most browsers.
+ */
+public class FocusImplStandard extends FocusImpl {
+
+ /*
+ * Use isolated method calls to create all of the handlers to avoid
creating
+ * memory leaks via handler-closures-element.
+ */
+ JavaScriptObject focusHandler = createFocusHandler();
+
+ @Override
+ public native Element createFocusable() /*-{
+ // Divs are focusable in all browsers, but only IE supports the
accessKey
+ // property on divs. We use the infamous 'hidden input' trick to add an
+ // accessKey to the focusable div. Note that the input is only used to
+ // capture focus when the accessKey is pressed. Focus is forwarded to
the
+ // div immediately.
+ var div = $doc.createElement('div');
+ div.tabIndex = 0;
+
+ var input = $doc.createElement('input');
+ input.type = 'text';
+ input.tabIndex = -1;
+ input.style.opacity = 0;
+ input.style.height = '1px';
+ input.style.width = '1px';
+ input.style.zIndex = -1;
+ input.style.overflow = 'hidden';
+ input.style.position = 'absolute';
+
+ // Note that we're using isolated lambda methods as the event listeners
+ // to avoid creating a memory leaks. (Lambdas here would create cycles
+ // involving the div and input). This also allows us to share a single
+ // set of handlers among every focusable item.
+ input.addEventListener(
+ 'focus',
+
[email protected]::focusHandler,
+ false);
+
+ div.appendChild(input);
+ return div;
+ }-*/;
+
+ @Override
+ public native void setAccessKey(Element elem, char key) /*-{
+ elem.firstChild.accessKey = String.fromCharCode(key);
+ }-*/;
+
+ private native JavaScriptObject createFocusHandler() /*-{
+ return function(evt) {
+ // This function is called directly as an event handler, so 'this' is
+ // set up by the browser to be the input on which the event is
fired. We
+ // call focus() in a timeout or the element may be blurred when this
event
+ // ends.
+ var div = this.parentNode;
+ if (div.onfocus) {
+ $wnd.setTimeout(function() {
+ div.focus();
+ }, 0);
+ }
+ };
+ }-*/;
+}
=======================================
---
/releases/2.0/user/src/com/google/gwt/user/client/ui/impl/FocusImplOld.java
Fri Aug 24 15:31:25 2007
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright 2007 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may
not
- * use this file except in compliance with the License. You may obtain a
copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
under
- * the License.
- */
-package com.google.gwt.user.client.ui.impl;
-
-import com.google.gwt.core.client.JavaScriptObject;
-import com.google.gwt.user.client.Element;
-
-/**
- * Crazy implementation of {...@link
com.google.gwt.user.client.ui.impl.FocusImpl}
- * that uses a hidden anchor to serve as a 'proxy' for focus.
- */
-public class FocusImplOld extends FocusImpl {
-
- /*
- * Use isolated method calls to create all of the handlers to avoid
creating
- * memory leaks via handler-closures-element.
- */
- JavaScriptObject blurHandler = createBlurHandler();
- JavaScriptObject focusHandler = createFocusHandler();
- JavaScriptObject mouseHandler = createMouseHandler();
-
- @Override
- public native void blur(Element elem) /*-{
- elem.firstChild.blur();
- }-*/;
-
- @Override
- public native Element createFocusable() /*-{
- // Use the infamous 'hidden input' trick to make a div effectively
- // focusable.
- var div = $doc.createElement('div');
- var input =
[email protected]::createHiddenInput()();
-
- // Add a mousedown listener to the div to focuses the input (to mimic
the
- // behavior of focusable elements on other browsers), and focus
listeners
- // on the input to propagate focus events back to the div.
-
- // Note that we're using isolated lambda methods as the event listeners
- // to avoid creating a memory leaks. (Lambdas here would create cycles
- // involving the div and input). This also allows us to share a single
- // set of handlers among every focusable item.
-
- input.addEventListener(
- 'blur',
- [email protected]::blurHandler,
- false);
-
- input.addEventListener(
- 'focus',
- [email protected]::focusHandler,
- false);
-
- div.addEventListener(
- 'mousedown',
- [email protected]::mouseHandler,
- false);
-
- div.appendChild(input);
- return div;
- }-*/;
-
- @Override
- public native void focus(Element elem) /*-{
- elem.firstChild.focus();
- }-*/;
-
- @Override
- public native int getTabIndex(Element elem) /*-{
- return elem.firstChild.tabIndex;
- }-*/;
-
- @Override
- public native void setAccessKey(Element elem, char key) /*-{
- elem.firstChild.accessKey = key;
- }-*/;
-
- @Override
- public native void setTabIndex(Element elem, int index) /*-{
- elem.firstChild.tabIndex = index;
- }-*/;
-
- protected native JavaScriptObject createBlurHandler() /*-{
- return function(evt) {
- // This function is called directly as an event handler, so 'this' is
- // set up by the browser to be the input on which the event is fired.
- if (this.parentNode.onblur) {
- this.parentNode.onblur(evt);
- }
- };
- }-*/;
-
- protected native JavaScriptObject createFocusHandler() /*-{
- return function(evt) {
- // This function is called directly as an event handler, so 'this' is
- // set up by the browser to be the input on which the event is fired.
- if (this.parentNode.onfocus) {
- this.parentNode.onfocus(evt);
- }
- };
- }-*/;
-
- protected native Element createHiddenInput() /*-{
- var input = $doc.createElement('input');
- input.type = 'text';
- input.style.width = input.style.height = 0;
- input.style.zIndex = -1;
- input.style.position = 'absolute';
- return input;
- }-*/;
-
- protected native JavaScriptObject createMouseHandler() /*-{
- return function() {
- // This function is called directly as an event handler, so 'this' is
- // set up by the browser to be the div on which the event is fired.
- this.firstChild.focus();
- };
- }-*/;
-}
=======================================
--- /releases/2.0/branch-info.txt Fri Jan 15 13:46:43 2010
+++ /releases/2.0/branch-info.txt Fri Jan 15 13:48:32 2010
@@ -1225,3 +1225,7 @@
tr...@7371 was merged into this branch
Updates the deprecation javadoc for RichTextArea.BasicFormatter.
svn merge --ignore-ancestry -c 7371
http://google-web-toolkit.googlecode.com/svn/trunk .
+
+tr...@7390 was merged into this branch
+ Refactor of FocusImpl.
+ svn merge --ignore-ancestry -c 7390
http://google-web-toolkit.googlecode.com/svn/trunk .
=======================================
--- /releases/2.0/user/src/com/google/gwt/dom/client/AnchorElement.java Thu
Jul 16 10:46:04 2009
+++ /releases/2.0/user/src/com/google/gwt/dom/client/AnchorElement.java Fri
Jan 15 13:48:32 2010
@@ -36,20 +36,6 @@
protected AnchorElement() {
}
-
- /**
- * Removes keyboard focus from this element.
- */
- public final native void blur() /*-{
- this.blur();
- }-*/;
-
- /**
- * Gives keyboard focus to this element.
- */
- public final native void focus() /*-{
- this.focus();
- }-*/;
/**
* A single character access key to give access to the form control.
@@ -96,15 +82,6 @@
return this.rel;
}-*/;
- /**
- * Index that represents the element's position in the tabbing order.
- *
- * @see <a
href="http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-tabindex">W3C
HTML Specification</a>
- */
- public final native int getTabIndex() /*-{
- return this.tabIndex;
- }-*/;
-
/**
* Frame to render the resource in.
*
@@ -168,15 +145,6 @@
this.rel = rel;
}-*/;
- /**
- * Index that represents the element's position in the tabbing order.
- *
- * @see <a
href="http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-tabindex">W3C
HTML Specification</a>
- */
- public final native void setTabIndex(int tabIndex) /*-{
- this.tabIndex = tabIndex;
- }-*/;
-
/**
* Frame to render the resource in.
*
=======================================
--- /releases/2.0/user/src/com/google/gwt/dom/client/AreaElement.java Fri
Jul 11 13:35:23 2008
+++ /releases/2.0/user/src/com/google/gwt/dom/client/AreaElement.java Fri
Jan 15 13:48:32 2010
@@ -84,15 +84,6 @@
return this.shape;
}-*/;
- /**
- * Index that represents the element's position in the tabbing order.
- *
- * @see <a
href="http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-tabindex">W3C
HTML Specification</a>
- */
- public final native int getTabIndex() /*-{
- return this.tabIndex;
- }-*/;
-
/**
* Frame to render the resource in.
*
@@ -149,15 +140,6 @@
this.shape = shape;
}-*/;
- /**
- * Index that represents the element's position in the tabbing order.
- *
- * @see <a
href="http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-tabindex">W3C
HTML Specification</a>
- */
- public final native void setTabIndex(int tabIndex) /*-{
- this.tabIndex = tabIndex;
- }-*/;
-
/**
* Frame to render the resource in.
*
=======================================
--- /releases/2.0/user/src/com/google/gwt/dom/client/ButtonElement.java Fri
May 15 13:11:37 2009
+++ /releases/2.0/user/src/com/google/gwt/dom/client/ButtonElement.java Fri
Jan 15 13:48:32 2010
@@ -80,15 +80,6 @@
return this.name;
}-*/;
- /**
- * Index that represents the element's position in the tabbing order.
- *
- * @see <a
href="http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-tabindex">W3C
HTML Specification</a>
- */
- public final native int getTabIndex() /*-{
- return this.tabIndex;
- }-*/;
-
/**
* The type of button (all lower case).
*
@@ -153,15 +144,6 @@
this.name = name;
}-*/;
- /**
- * Index that represents the element's position in the tabbing order.
- *
- * @see <a
href="http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-tabindex">W3C
HTML Specification</a>
- */
- public final native void setTabIndex(int tabIndex) /*-{
- this.tabIndex = tabIndex;
- }-*/;
-
/**
* The current form control value.
*
=======================================
--- /releases/2.0/user/src/com/google/gwt/dom/client/Element.java Fri Nov
20 11:47:11 2009
+++ /releases/2.0/user/src/com/google/gwt/dom/client/Element.java Fri Jan
15 13:48:32 2010
@@ -102,6 +102,13 @@
setClassName(oldClassName + className);
}
}
+
+ /**
+ * Removes keyboard focus from this element.
+ */
+ public final native void blur() /*-{
+ this.blur();
+ }-*/;
/**
* Dispatched the given event with this element as its target. The event
will
@@ -119,6 +126,13 @@
public final void dispatchEvent(NativeEvent evt) {
DOMImpl.impl.dispatchEvent(this, evt);
}
+
+ /**
+ * Gives keyboard focus to this element.
+ */
+ public final native void focus() /*-{
+ this.focus();
+ }-*/;
/**
* Gets an element's absolute bottom coordinate in the document's
coordinate
@@ -417,6 +431,15 @@
return this.style;
}-*/;
+ /**
+ * The index that represents the element's position in the tabbing order.
+ *
+ * @see <a
href="http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-tabindex">W3C
HTML Specification</a>
+ */
+ public final native int getTabIndex() /*-{
+ return this.tabIndex;
+ }-*/;
+
/**
* Gets the element's full tag name, including the namespace-prefix if
* present.
@@ -679,6 +702,15 @@
this.scrollTop = scrollTop;
}-*/;
+ /**
+ * The index that represents the element's position in the tabbing order.
+ *
+ * @see <a
href="http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-tabindex">W3C
HTML Specification</a>
+ */
+ public final native void setTabIndex(int tabIndex) /*-{
+ this.tabIndex = tabIndex;
+ }-*/;
+
/**
* The element's advisory title.
*/
=======================================
--- /releases/2.0/user/src/com/google/gwt/dom/client/InputElement.java Fri
May 15 13:11:37 2009
+++ /releases/2.0/user/src/com/google/gwt/dom/client/InputElement.java Fri
Jan 15 13:48:32 2010
@@ -41,13 +41,6 @@
protected InputElement() {
}
-
- /**
- * Removes keyboard focus from this element.
- */
- public final native void blur() /*-{
- this.blur();
- }-*/;
/**
* Simulate a mouse-click. For INPUT elements whose type attribute has
one of
@@ -57,13 +50,6 @@
this.click();
}-*/;
- /**
- * Gives keyboard focus to this element.
- */
- public final native void focus() /*-{
- this.focus();
- }-*/;
-
/**
* A comma-separated list of content types that a server processing this
form
* will handle correctly.
@@ -151,15 +137,6 @@
return this.src;
}-*/;
- /**
- * Index that represents the element's position in the tabbing order.
- *
- * @see <a
href="http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-tabindex">W3C
HTML Specification</a>
- */
- public final native int getTabIndex() /*-{
- return this.tabIndex;
- }-*/;
-
/**
* The type of control created (all lower case).
*
@@ -371,15 +348,6 @@
this.src = src;
}-*/;
- /**
- * Index that represents the element's position in the tabbing order.
- *
- * @see <a
href="http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-tabindex">W3C
HTML Specification</a>
- */
- public final native void setTabIndex(int tabIndex) /*-{
- this.tabIndex = tabIndex;
- }-*/;
-
/**
* Use client-side image map.
*
=======================================
--- /releases/2.0/user/src/com/google/gwt/dom/client/ObjectElement.java Fri
Jul 11 13:35:23 2008
+++ /releases/2.0/user/src/com/google/gwt/dom/client/ObjectElement.java Fri
Jan 15 13:48:32 2010
@@ -91,15 +91,6 @@
return this.name;
}-*/;
- /**
- * Index that represents the element's position in the tabbing order.
- *
- * @see <a
href="http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-tabindex">W3C
HTML Specification</a>
- */
- public final native int getTabIndex() /*-{
- return this.tabIndex;
- }-*/;
-
/**
* Content type for data downloaded via data attribute.
*
@@ -152,15 +143,6 @@
this.name = name;
}-*/;
- /**
- * Index that represents the element's position in the tabbing order.
- *
- * @see <a
href="http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-tabindex">W3C
HTML Specification</a>
- */
- public final native void setTabIndex(int tabIndex) /*-{
- this.tabIndex = tabIndex;
- }-*/;
-
/**
* Content type for data downloaded via data attribute.
*
=======================================
--- /releases/2.0/user/src/com/google/gwt/dom/client/SelectElement.java Tue
Nov 17 11:54:37 2009
+++ /releases/2.0/user/src/com/google/gwt/dom/client/SelectElement.java Fri
Jan 15 13:48:32 2010
@@ -54,13 +54,6 @@
public final void add(OptionElement option, OptionElement before) {
DOMImpl.impl.selectAdd(this, option, before);
}
-
- /**
- * Removes keyboard focus from this element.
- */
- public final native void blur() /*-{
- this.blur();
- }-*/;
/**
* Removes all OPTION elements from this SELECT.
@@ -68,13 +61,6 @@
public final void clear() {
DOMImpl.impl.selectClear(this);
}
-
- /**
- * Gives keyboard focus to this element.
- */
- public final native void focus() /*-{
- this.focus();
- }-*/;
/**
* The control is unavailable in this context.
=======================================
--- /releases/2.0/user/src/com/google/gwt/dom/client/TextAreaElement.java
Fri May 15 13:11:37 2009
+++ /releases/2.0/user/src/com/google/gwt/dom/client/TextAreaElement.java
Fri Jan 15 13:48:32 2010
@@ -36,20 +36,6 @@
protected TextAreaElement() {
}
-
- /**
- * Removes keyboard focus from this element.
- */
- public final native void blur() /*-{
- this.blur();
- }-*/;
-
- /**
- * Gives keyboard focus to this element.
- */
- public final native void focus() /*-{
- this.focus();
- }-*/;
/**
* A single character access key to give access to the form control.
@@ -118,15 +104,6 @@
return this.rows;
}-*/;
- /**
- * Index that represents the element's position in the tabbing order.
- *
- * @see <a
href="http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-tabindex">W3C
HTML Specification</a>
- */
- public final native int getTabIndex() /*-{
- return this.tabIndex;
- }-*/;
-
/**
* The type of this form control. This the string "textarea".
*/
@@ -233,15 +210,6 @@
this.rows = rows;
}-*/;
- /**
- * Index that represents the element's position in the tabbing order.
- *
- * @see <a
href="http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-tabindex">W3C
HTML Specification</a>
- */
- public final native void setTabIndex(int tabIndex) /*-{
- this.tabIndex = tabIndex;
- }-*/;
-
/**
* Represents the current contents of the corresponding form control, in
an
* interactive user agent. Changing this attribute changes the contents
of the
=======================================
--- /releases/2.0/user/src/com/google/gwt/user/Focus.gwt.xml Tue Apr 28
09:11:39 2009
+++ /releases/2.0/user/src/com/google/gwt/user/Focus.gwt.xml Fri Jan 15
13:48:32 2010
@@ -20,15 +20,17 @@
<inherits name="com.google.gwt.core.Core"/>
<inherits name="com.google.gwt.user.UserAgent"/>
- <!-- old Mozilla needs a different implementation -->
- <replace-with class="com.google.gwt.user.client.ui.impl.FocusImplOld">
+ <!-- Firefox uses a hidden input to set accesskeys -->
+ <replace-with
class="com.google.gwt.user.client.ui.impl.FocusImplStandard">
<when-type-is class="com.google.gwt.user.client.ui.impl.FocusImpl"/>
<any>
<when-property-is name="user.agent" value="gecko"/>
+ <when-property-is name="user.agent" value="gecko1_8"/>
</any>
</replace-with>
- <!-- Safari needs a different hidden input -->
+ <!-- Safari uses a hidden input to set accesskeys and -->
+ <!-- fires focus/blur after a timeout -->
<replace-with class="com.google.gwt.user.client.ui.impl.FocusImplSafari">
<when-type-is class="com.google.gwt.user.client.ui.impl.FocusImpl"/>
<when-property-is name="user.agent" value="safari"/>
=======================================
---
/releases/2.0/user/src/com/google/gwt/user/client/ui/impl/FocusImpl.java
Fri Aug 24 15:31:25 2007
+++
/releases/2.0/user/src/com/google/gwt/user/client/ui/impl/FocusImpl.java
Fri Jan 15 13:48:32 2010
@@ -16,6 +16,7 @@
package com.google.gwt.user.client.ui.impl;
import com.google.gwt.core.client.GWT;
+import com.google.gwt.dom.client.Document;
import com.google.gwt.user.client.Element;
/**
@@ -23,20 +24,20 @@
* that aren't naturally focusable in all browsers, such as DIVs.
*/
public class FocusImpl {
-
+
private static FocusImpl implPanel = GWT.create(FocusImpl.class);
/**
- * This instance may not be a {...@link FocusImplOld}, because that special
case
- * is only needed for things that aren't naturally focusable on some
browsers,
- * such as DIVs. This exact class works for truly focusable widgets on
those
- * browsers.
+ * This instance may not be a {...@link FocusImplStandard}, because that
special
+ * case is only needed for things that aren't naturally focusable on some
+ * browsers, such as DIVs. This exact class works for truly focusable
widgets
+ * on those browsers.
*
* The compiler will optimize out the conditional.
*/
- private static FocusImpl implWidget = (implPanel instanceof FocusImplOld)
+ private static FocusImpl implWidget = (implPanel instanceof
FocusImplStandard)
? new FocusImpl() : implPanel;
-
+
/**
* Returns the focus implementation class for creating and manipulating
* focusable elements that aren't naturally focusable in all browsers,
such as
@@ -45,7 +46,7 @@
public static FocusImpl getFocusImplForPanel() {
return implPanel;
}
-
+
/**
* Returns the focus implementation class for manipulating focusable
elements
* that are naturally focusable in all browsers, such as text boxes.
@@ -53,36 +54,36 @@
public static FocusImpl getFocusImplForWidget() {
return implWidget;
}
-
+
/**
- * Not externally instantiable or extensible.
+ * Not externally instantiable or extensible.
*/
FocusImpl() {
}
- public native void blur(Element elem) /*-{
+ public void blur(Element elem) {
elem.blur();
- }-*/;
-
- public native Element createFocusable() /*-{
- var e = $doc.createElement("DIV");
- e.tabIndex = 0;
+ }
+
+ public Element createFocusable() {
+ Element e = Document.get().createDivElement().cast();
+ e.setTabIndex(0);
return e;
- }-*/;
-
- public native void focus(Element elem) /*-{
+ }
+
+ public void focus(Element elem) {
elem.focus();
- }-*/;
-
- public native int getTabIndex(Element elem) /*-{
- return elem.tabIndex;
- }-*/;
+ }
+
+ public int getTabIndex(Element elem) {
+ return elem.getTabIndex();
+ }
public native void setAccessKey(Element elem, char key) /*-{
- elem.accessKey = key;
+ elem.accessKey = String.fromCharCode(key);
}-*/;
- public native void setTabIndex(Element elem, int index) /*-{
- elem.tabIndex = index;
- }-*/;
-}
+ public void setTabIndex(Element elem, int index) {
+ elem.setTabIndex(index);
+ }
+}
=======================================
---
/releases/2.0/user/src/com/google/gwt/user/client/ui/impl/FocusImplSafari.java
Fri Aug 24 15:31:25 2007
+++
/releases/2.0/user/src/com/google/gwt/user/client/ui/impl/FocusImplSafari.java
Fri Jan 15 13:48:32 2010
@@ -15,7 +15,6 @@
*/
package com.google.gwt.user.client.ui.impl;
-import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.user.client.Element;
/**
@@ -23,14 +22,14 @@
* transparent hidden element, since Safari will not keyboard focus on an
input
* element that has zero width and height.
*/
-public class FocusImplSafari extends FocusImplOld {
-
+public class FocusImplSafari extends FocusImplStandard {
+
@Override
public native void blur(Element elem) /*-{
// Attempts to blur elements from within an event callback will
generally
// be unsuccessful, so we invoke blur() from outside of the callback.
$wnd.setTimeout(function() {
- elem.firstChild.blur();
+ elem.blur();
}, 0);
}-*/;
@@ -39,36 +38,8 @@
// Attempts to focus elements from within an event callback will
generally
// be unsuccessful, so we invoke focus() from outside of the callback.
$wnd.setTimeout(function() {
- elem.firstChild.focus();
+ elem.focus();
}, 0);
}-*/;
- @Override
- protected native Element createHiddenInput() /*-{
- var input = $doc.createElement('input');
- input.type = 'text';
- input.style.opacity = 0;
- input.style.zIndex = -1;
- input.style.height = '1px';
- input.style.width = '1px';
- input.style.overflow = 'hidden';
- input.style.position = 'absolute';
- return input;
- }-*/;
-
- @Override
- protected native JavaScriptObject createMouseHandler() /*-{
- return function() {
- // This function is called directly as an event handler, so 'this' is
- // set up by the browser to be the div on which the event is fired.
- var firstChild = this.firstChild;
-
- // Attempts to focus elements from within an event callback will
generally
- // be unsuccessful, so we invoke focus() from outside of the
callback.
- $wnd.setTimeout(function() {
- firstChild.focus();
- }, 0);
- }
- }-*/;
-
-}
+}
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors