Search in sources :

Example 1 with ManagedCombo

use of edu.cmu.cs.hcii.cogtool.util.ManagedCombo in project cogtool by cogtool.

the class SWTMouseState method dealWithEvent.

// Force subclasses to implement the "dealWith" versions
protected void dealWithEvent(Event evt) {
    // if on Windows, handle contextual menu key
    if (evt.type == SWT.MenuDetect) {
        // isMenuClick true means a right-click; need location!
        if (OSUtils.MACOSX || isMenuClick) {
            Control c = (Control) evt.widget;
            Text focusedText = WindowUtil.getFocusedText();
            if (focusedText != null) {
                if (focusedText instanceof ManagedText) {
                    ManagedText txt = (ManagedText) focusedText;
                    if (!txt.confirm(ManagedText.LOSE_FOCUS)) {
                        return;
                    }
                }
                c.forceFocus();
            }
            Combo focusedCombo = WindowUtil.getFocusedCombo();
            if (focusedCombo != null) {
                if (focusedCombo instanceof ManagedCombo) {
                    ManagedCombo combo = (ManagedCombo) focusedCombo;
                    if (!combo.confirm(ManagedCombo.LOSE_FOCUS)) {
                        return;
                    }
                }
                c.forceFocus();
            }
            Point p = c.toControl(evt.x, evt.y);
            menuUI.showContextMenu(p.x, p.y);
        } else {
            menuUI.showContextMenu();
        }
    }
}
Also used : Control(org.eclipse.swt.widgets.Control) ManagedCombo(edu.cmu.cs.hcii.cogtool.util.ManagedCombo) ManagedText(edu.cmu.cs.hcii.cogtool.util.ManagedText) Text(org.eclipse.swt.widgets.Text) ManagedText(edu.cmu.cs.hcii.cogtool.util.ManagedText) Combo(org.eclipse.swt.widgets.Combo) ManagedCombo(edu.cmu.cs.hcii.cogtool.util.ManagedCombo) Point(org.eclipse.swt.graphics.Point)

Example 2 with ManagedCombo

use of edu.cmu.cs.hcii.cogtool.util.ManagedCombo in project cogtool by cogtool.

the class Draw2DMouseState method dealWithEvent.

// Force subclasses to implement the "dealWith" versions
/**
     * Returns true if subclass processing should continue, false
     * if subclass processing should be terminated.
     */
protected boolean dealWithEvent(Event evt) {
    if (evt.type == SWT.MenuDetect) {
        // that each of our windows using Draw2D contains only one Canvas!
        if (isMenuClick || (OSUtils.MACOSX && (evt.widget instanceof Canvas))) {
            Canvas c = (Canvas) evt.widget;
            Text focusedText = WindowUtil.getFocusedText();
            if (focusedText != null) {
                if (focusedText instanceof ManagedText) {
                    ManagedText txt = (ManagedText) focusedText;
                    if (!txt.confirm(ManagedText.LOSE_FOCUS)) {
                        return false;
                    }
                }
                c.forceFocus();
            }
            Combo focusedCombo = WindowUtil.getFocusedCombo();
            if (focusedCombo != null) {
                if (focusedCombo instanceof ManagedCombo) {
                    ManagedCombo combo = (ManagedCombo) focusedCombo;
                    if (!combo.confirm(ManagedCombo.LOSE_FOCUS)) {
                        return false;
                    }
                }
                c.forceFocus();
            }
            Point p = c.toControl(evt.x, evt.y);
            menuUI.showContextMenu(p.x, p.y);
        } else {
            menuUI.showContextMenu();
        }
    }
    return true;
}
Also used : ManagedCombo(edu.cmu.cs.hcii.cogtool.util.ManagedCombo) Canvas(org.eclipse.swt.widgets.Canvas) ManagedText(edu.cmu.cs.hcii.cogtool.util.ManagedText) Text(org.eclipse.swt.widgets.Text) ManagedText(edu.cmu.cs.hcii.cogtool.util.ManagedText) Combo(org.eclipse.swt.widgets.Combo) ManagedCombo(edu.cmu.cs.hcii.cogtool.util.ManagedCombo) Point(org.eclipse.swt.graphics.Point)

Aggregations

ManagedCombo (edu.cmu.cs.hcii.cogtool.util.ManagedCombo)2 ManagedText (edu.cmu.cs.hcii.cogtool.util.ManagedText)2 Point (org.eclipse.swt.graphics.Point)2 Combo (org.eclipse.swt.widgets.Combo)2 Text (org.eclipse.swt.widgets.Text)2 Canvas (org.eclipse.swt.widgets.Canvas)1 Control (org.eclipse.swt.widgets.Control)1