import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.UIObject;
import com.google.gwt.user.client.ui.Widget;
+
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.BrowserInfo;
import com.vaadin.terminal.gwt.client.Container;
}
}
- private void handleClickEvent(Event event, Element targetTdOrTr) {
- if (client.hasEventListeners(VScrollTable.this,
+ /**
+ * If there are registered click listeners, sends a click event and
+ * returns true. Otherwise, does nothing and returns false.
+ *
+ * @param event
+ * @param targetTdOrTr
+ * @param immediate
+ * Whether the event is sent immediately
+ * @return Whether a click event was sent
+ */
+ private boolean handleClickEvent(Event event, Element targetTdOrTr,
+ boolean immediate) {
+ if (!client.hasEventListeners(VScrollTable.this,
ITEM_CLICK_EVENT_ID)) {
- boolean doubleClick = (DOM.eventGetType(event) == Event.ONDBLCLICK);
-
- /* This row was clicked */
- client.updateVariable(paintableId, "clickedKey", ""
- + rowKey, false);
-
- if (getElement() == targetTdOrTr.getParentElement()) {
- /* A specific column was clicked */
- int childIndex = DOM.getChildIndex(getElement(),
- targetTdOrTr);
- String colKey = null;
- colKey = tHead.getHeaderCell(childIndex).getColKey();
- client.updateVariable(paintableId, "clickedColKey",
- colKey, false);
- }
-
- MouseEventDetails details = new MouseEventDetails(event);
+ // Don't send an event if nobody is listening
+ return false;
+ }
- boolean imm = true;
- if (immediate && event.getButton() == Event.BUTTON_LEFT
- && !doubleClick && isSelectable() && !isSelected()) {
- /*
- * A left click when the table is selectable and in
- * immediate mode on a row that is not currently
- * selected will cause a selection event to be fired
- * after this click event. By making the click event
- * non-immediate we avoid sending two separate messages
- * to the server.
- */
- imm = false;
- }
+ // This row was clicked
+ client.updateVariable(paintableId, "clickedKey", "" + rowKey,
+ false);
- client.updateVariable(paintableId, "clickEvent",
- details.toString(), imm);
+ if (getElement() == targetTdOrTr.getParentElement()) {
+ // A specific column was clicked
+ int childIndex = DOM.getChildIndex(getElement(),
+ targetTdOrTr);
+ String colKey = null;
+ colKey = tHead.getHeaderCell(childIndex).getColKey();
+ client.updateVariable(paintableId, "clickedColKey", colKey,
+ false);
}
+
+ MouseEventDetails details = new MouseEventDetails(event);
+
+ client.updateVariable(paintableId, "clickEvent",
+ details.toString(), immediate);
+
+ return true;
}
private void handleTooltips(final Event event, Element target) {
&& (actionKeys != null || client
.hasEventListeners(VScrollTable.this,
ITEM_CLICK_EVENT_ID))) {
- // Prevent browser context menu only if there are
- // action handlers or item click listeners
- // registered
+ /*
+ * Prevent browser context menu only if there are
+ * action handlers or item click listeners
+ * registered
+ */
event.stopPropagation();
event.preventDefault();
}
switch (type) {
case Event.ONDBLCLICK:
if (targetCellOrRowFound) {
- handleClickEvent(event, targetTdOrTr);
+ handleClickEvent(event, targetTdOrTr, immediate);
}
break;
case Event.ONMOUSEUP:
if (targetCellOrRowFound) {
mDown = false;
- handleClickEvent(event, targetTdOrTr);
+ /*
+ * Queue here, send at the same time as the
+ * corresponding value change event - see #7127
+ */
+ boolean clickEventSent = handleClickEvent(event,
+ targetTdOrTr, false);
+
if (event.getButton() == Event.BUTTON_LEFT
&& isSelectable()) {
.setPropertyJSO("onselectstart",
null);
}
- sendSelectedRows();
+ // Queue value change
+ sendSelectedRows(false);
+ }
+ /*
+ * Send queued click and value change events if any
+ * If a click event is sent, send value change with
+ * it regardless of the immediate flag, see #7127
+ */
+ if (immediate || clickEventSent) {
+ client.sendPendingVariableChanges();
}
}
break;