Browse Source

maybe fixes #6834 (can't reproduce as described, but this fixes an other related (possibly same) issue with Firefox 4)

svn changeset:18588/svn branch:6.6
tags/6.7.0.beta1
Matti Tahvonen 13 years ago
parent
commit
22e8f6cd84

+ 35
- 0
src/com/vaadin/terminal/gwt/client/Util.java View File

return null; return null;
}-*/ }-*/
; ;

/**
* Kind of stronger version of isAttached(). In addition to std isAttached,
* this method checks that this widget nor any of its parents is hidden. Can
* be e.g used to check whether component should react to some events or
* not.
*
* @param widget
* @return true if attached and displayed
*/
public static boolean isAttachedAndDisplayed(Widget widget) {
if (widget.isAttached()) {
/*
* Failfast using offset size, then by iterating the widget tree
*/
boolean notZeroSized = widget.getOffsetHeight() > 0
|| widget.getOffsetWidth() > 0;
return notZeroSized || checkVisibilityRecursively(widget);
} else {
return false;
}
}

private static boolean checkVisibilityRecursively(Widget widget) {
if (widget.isVisible()) {
Widget parent = widget.getParent();
if (parent == null) {
return true; // root panel
} else {
return checkVisibilityRecursively(parent);
}
} else {
return false;
}
}
} }

+ 9
- 7
src/com/vaadin/terminal/gwt/client/ui/VTextField.java View File

import com.vaadin.terminal.gwt.client.Paintable; import com.vaadin.terminal.gwt.client.Paintable;
import com.vaadin.terminal.gwt.client.UIDL; import com.vaadin.terminal.gwt.client.UIDL;
import com.vaadin.terminal.gwt.client.Util; import com.vaadin.terminal.gwt.client.Util;
import com.vaadin.terminal.gwt.client.VConsole;
import com.vaadin.terminal.gwt.client.VTooltip; import com.vaadin.terminal.gwt.client.VTooltip;
import com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler.BeforeShortcutActionListener; import com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler.BeforeShortcutActionListener;


* @return true iff the value was updated * @return true iff the value was updated
*/ */
protected boolean updateCursorPosition() { protected boolean updateCursorPosition() {
int cursorPos = getCursorPos();
if (lastCursorPos != cursorPos) {
client.updateVariable(id, VAR_CURSOR, cursorPos, false);
lastCursorPos = cursorPos;
return true;
} else {
return false;
if (Util.isAttachedAndDisplayed(this)) {
int cursorPos = getCursorPos();
if (lastCursorPos != cursorPos) {
client.updateVariable(id, VAR_CURSOR, cursorPos, false);
lastCursorPos = cursorPos;
return true;
}
} }
return false;
} }


private static VTextField focusedTextField; private static VTextField focusedTextField;

Loading…
Cancel
Save