* Prevent the keyboard focus from leaving the textfield by
* preventing the default behaviour of the browser. Fixes #4285.
*/
- if (event.getTypeInt() == Event.ONMOUSEDOWN) {
- event.preventDefault();
- event.stopPropagation();
-
- /*
- * In IE the above wont work, the blur event will still trigger.
- * So, we set a flag here to prevent the next blur event from
- * happening.
- */
- if (BrowserInfo.get().isIE()) {
- iePreventNextBlur = true;
- }
- }
+ handleMouseDownEvent(event);
}
/**
/**
* Used when measuring the width of the popup
*/
- boolean iePreventNextBlur = false;
+
private final HTML popupOpener = new HTML("") {
/*
* Prevent the keyboard focus from leaving the textfield by
* preventing the default behaviour of the browser. Fixes #4285.
*/
- if (event.getTypeInt() == Event.ONMOUSEDOWN) {
- event.preventDefault();
- event.stopPropagation();
-
- /*
- * In IE the above wont work, the blur event will still trigger.
- * So, we set a flag here to prevent the next blur event from
- * happening.
- */
- if (BrowserInfo.get().isIE()) {
- iePreventNextBlur = true;
- }
- }
+ handleMouseDownEvent(event);
}
};
updateRootWidth();
}
- // Style dependant style names are lost during the update, so we add
+ // Focus dependent style names are lost during the update, so we add
// them here back again
if (focused) {
addStyleDependentName("focus");
return w;
}-*/;
+
+ /**
+ * A flag which prevents a focus event from taking place
+ */
+ boolean iePreventNextFocus = false;
+
/*
* (non-Javadoc)
*
}
}
+ /**
+ * A flag which cancels the blur event and sets the focus back to the
+ * textfield if the Browser is IE
+ */
+ boolean preventNextBlurEventInIE = false;
+
/*
* (non-Javadoc)
*
* com.google.gwt.event.dom.client.BlurHandler#onBlur(com.google.gwt.event
* .dom.client.BlurEvent)
*/
- boolean iePreventNextFocus = false;
+
public void onBlur(BlurEvent event) {
/*
* triggered by a mouseclick which we cannot prevent. In this cases we
* refocus the textfield and ignore the blur event.
*/
- if (BrowserInfo.get().isIE() && iePreventNextBlur) {
- iePreventNextBlur = false;
+ if (BrowserInfo.get().isIE() && preventNextBlurEventInIE) {
+ preventNextBlurEventInIE = false;
// Move the focus back to the textfield without triggering a
// onFocus-event
}
return componentPadding;
}
+
+ /**
+ * Handles special behavior of the mouse down event
+ *
+ * @param event
+ */
+ private void handleMouseDownEvent(Event event) {
+ /*
+ * Prevent the keyboard focus from leaving the textfield by preventing
+ * the default behaviour of the browser. Fixes #4285.
+ */
+ if (event.getTypeInt() == Event.ONMOUSEDOWN) {
+ event.preventDefault();
+ event.stopPropagation();
+
+ /*
+ * In IE the above wont work, the blur event will still trigger. So,
+ * we set a flag here to prevent the next blur event from happening.
+ */
+ if (BrowserInfo.get().isIE()) {
+ preventNextBlurEventInIE = true;
+ }
+ }
+ }
}