- If the menu is invoked with the mouse over the name space, then there
is no need to delay the menu detect handling until mouseUp, since the
right mouse button isn't being used to zoom
- If it is a pending menu detect callback on mouseUp, and another drag
operation is in progress or it is a drag zoom outside of the margin,
then make sure the menu is not made visible by setting e.doit to false.
- If the menu is invoked with the mouse over the name space, or with the
keyboard, if there is any drag operation in progress make sure the menu
is not made visible by setting e.doit to false.
- If the menu detect is handled immediately (not after a pending menu
detect on mouseUp) then there is no need to set the menu visible
programmatically since the platform will do it after the MenuDetect
event handling when e.doit is true.
Change-Id: I0d76b9908782fc853a065567a6e907da5e2d9c86
Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-on: https://git.eclipse.org/r/84434
Reviewed-by: Hudson CI
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
return Math.abs(x - nameWidth) < SNAP_WIDTH;
}
return Math.abs(x - nameWidth) < SNAP_WIDTH;
}
+ boolean isOverTimeSpace(int x, int y) {
+ Point size = getSize();
+ return x >= fTimeProvider.getNameSpace() && x < size.x && y >= 0 && y < size.y;
+ }
/**
* Gets the {@link ITimeGraphEntry} at the given location.
*
/**
* Gets the {@link ITimeGraphEntry} at the given location.
*
if (null == fTimeProvider) {
return;
}
if (null == fTimeProvider) {
return;
}
+ /*
+ * This flag indicates if menu was prevented from being shown below and
+ * therefore must be made visible on callback from mouseUp().
+ */
+ boolean pendingEventCallback = fPendingMenuDetectEvent != null;
Point p = toControl(e.x, e.y);
Point p = toControl(e.x, e.y);
- if (e.detail == SWT.MENU_MOUSE) {
+ if (e.detail == SWT.MENU_MOUSE && isOverTimeSpace(p.x, p.y)) {
if (fPendingMenuDetectEvent == null) {
/* Feature in Linux. The MenuDetectEvent is received before mouseDown.
* Store the event and trigger it later just before handling mouseUp.
if (fPendingMenuDetectEvent == null) {
/* Feature in Linux. The MenuDetectEvent is received before mouseDown.
* Store the event and trigger it later just before handling mouseUp.
*/
fPendingMenuDetectEvent = e;
/*
*/
fPendingMenuDetectEvent = e;
/*
- * Prevent the platform to show the menu when returning. The
- * menu will be shown (see below) when this method is called
- * again during mouseup().
+ * Prevent the platform to show the menu when returning. The
+ * menu will be shown (see below) when this method is called
+ * again during mouseUp().
*/
e.doit = false;
return;
}
fPendingMenuDetectEvent = null;
*/
e.doit = false;
return;
}
fPendingMenuDetectEvent = null;
- if ((p.x >= fTimeProvider.getNameSpace()) && (fDragState != DRAG_ZOOM || !isInDragZoomMargin())) {
+ if (fDragState != DRAG_ZOOM || !isInDragZoomMargin()) {
+ /*
+ * Don't show the menu on mouseUp() if a drag zoom is in
+ * progress with a drag range outside of the drag zoom margin,
+ * or if any other drag operation, or none, is in progress.
+ */
+ e.doit = false;
return;
}
} else {
if (fDragState != DRAG_NONE) {
return;
}
} else {
if (fDragState != DRAG_NONE) {
+ /*
+ * Don't show the menu on keyboard menu or mouse menu outside of
+ * the time space if any drag operation is in progress.
+ */
+ e.doit = false;
return;
}
}
int idx = getItemIndexAtY(p.y);
if (idx >= 0 && idx < fItemData.fExpandedItems.length) {
return;
}
}
int idx = getItemIndexAtY(p.y);
if (idx >= 0 && idx < fItemData.fExpandedItems.length) {
Item item = fItemData.fExpandedItems[idx];
ITimeGraphEntry entry = item.fEntry;
Item item = fItemData.fExpandedItems[idx];
ITimeGraphEntry entry = item.fEntry;
e.data = entry;
fireMenuEventOnTimeGraphEntry(e);
Menu menu = getMenu();
e.data = entry;
fireMenuEventOnTimeGraphEntry(e);
Menu menu = getMenu();
- if (e.doit && (menu != null)) {
+ if (pendingEventCallback && e.doit && (menu != null)) {
e.data = event;
fireMenuEventOnTimeEvent(e);
menu = getMenu();
e.data = event;
fireMenuEventOnTimeEvent(e);
menu = getMenu();
- if (e.doit && (menu != null)) {
+ if (pendingEventCallback && e.doit && (menu != null)) {
menu.setVisible(true);
}
}
menu.setVisible(true);
}
}