use of edu.cmu.cs.hcii.cogtool.uimodel.FrameEltGroupHalo in project cogtool by cogtool.
the class FrameEditorUI method showContextMenu.
/**
* Show a context menu at a specific X,Y Used for contextual menu's on
* unselected or selected objects.
*/
@Override
public void showContextMenu(int x, int y) {
// Check which region of the frame was hit
FrameEltSelnFig<?> eltFig = (FrameEltSelnFig<?>) frameUI.getFigureAtXY(x, y, FrameUIModel.ONLY_GRAPHICAL_WIDGETS);
// Check for appropriate MoveHalo
if (eltFig == null) {
MoveHalo halo = moveHaloUnderXY(x, y);
if (halo instanceof FrameEltGroupHalo) {
eltFig = (FrameEltGroupHalo) halo;
}
}
// Invocation in empty space?
if (eltFig == null) {
contextSelection.deselectAll();
showContextMenu(contextSelection, View.CONTEXT);
} else // Invocation on a selection widget
if (eltFig.isSelected()) {
showContextMenu();
Iterator<FrameEltSelnFig<?>> selectedFigs = selection.getSelectedFigures();
while (selectedFigs.hasNext()) {
FrameEltSelnFig<?> selectedFig = selectedFigs.next();
selectedFig.dynamicHighlight(true);
}
// The mac requires an additional repaint to display the highlight
if (OSUtils.MACOSX) {
updateUISupport();
}
} else // Invocation on an unselected widget
{
eltFig.dynamicHighlight(true);
// Populate the context selection
// This does not impact current selection, just the context one.
contextSelection.setSelectedSelnFig(eltFig);
// Display the correct context menu.
showContextMenu(contextSelection, View.CONTEXT);
// The mac requires an additional repaint to display highlighting
if (OSUtils.MACOSX) {
updateUISupport();
}
}
}
Aggregations