Search in sources :

Example 6 with ManagedText

use of edu.cmu.cs.hcii.cogtool.util.ManagedText 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

ManagedText (edu.cmu.cs.hcii.cogtool.util.ManagedText)6 Point (org.eclipse.swt.graphics.Point)3 FormAttachment (org.eclipse.swt.layout.FormAttachment)3 FormData (org.eclipse.swt.layout.FormData)3 Combo (org.eclipse.swt.widgets.Combo)3 DoubleEntry (edu.cmu.cs.hcii.cogtool.util.DoubleEntry)2 ManagedCombo (edu.cmu.cs.hcii.cogtool.util.ManagedCombo)2 Label (org.eclipse.swt.widgets.Label)2 Text (org.eclipse.swt.widgets.Text)2 AUndertaking (edu.cmu.cs.hcii.cogtool.model.AUndertaking)1 DisplayLabel (edu.cmu.cs.hcii.cogtool.util.DisplayLabel)1 IntegerEntry (edu.cmu.cs.hcii.cogtool.util.IntegerEntry)1 FormLayout (org.eclipse.swt.layout.FormLayout)1 RowLayout (org.eclipse.swt.layout.RowLayout)1 Button (org.eclipse.swt.widgets.Button)1 Canvas (org.eclipse.swt.widgets.Canvas)1 Composite (org.eclipse.swt.widgets.Composite)1 Control (org.eclipse.swt.widgets.Control)1 Event (org.eclipse.swt.widgets.Event)1 Listener (org.eclipse.swt.widgets.Listener)1