use of edu.cmu.cs.hcii.cogtool.model.MouseButtonState in project cogtool by cogtool.
the class DesignExportToHTML method textSelect.
/**
* For checkboxes and radio buttons, clicking on the text should cause
* the widget to change selection. The exception to this is when the
* widget already has a left-click transition defined that is not a
* self-transition, since then it would override the onclick property.
* @param widget
* @return
*/
protected boolean textSelect(IWidget widget) {
Iterator<Transition> transitions = widget.getTransitions().values().iterator();
boolean leftClick = false;
while (transitions.hasNext()) {
Transition transition = transitions.next();
AAction action = transition.getAction();
if (action instanceof ButtonAction) {
ButtonAction bAction = (ButtonAction) action;
MouseButtonState buttonState = bAction.getButton();
MousePressType pressType = bAction.getPressType();
if (MouseButtonState.Left.equals(buttonState) && MousePressType.Click.equals(pressType)) {
leftClick = true;
if (transition.getDestination().equals(widget.getFrame())) {
return true;
}
}
}
}
if (leftClick) {
return false;
}
return true;
}
use of edu.cmu.cs.hcii.cogtool.model.MouseButtonState in project cogtool by cogtool.
the class DesignExportToHTML method getMenuMap.
/**
* Return an array of three strings, corresponding to the three possible
* mouse buttons, representing either the name of the frame transitioned to
* by that button, or 'null'.
* NOTE: Hover and multiple-click transitions don't work with menu items.
*/
protected String getMenuMap(MenuItem child) {
String result = "[";
// TODO: onmouseup doesn't work for middle clicks...except
// sometimes it does, may be related to focus?
// Always use onmouseup instead of onclick because we need to check
// for double click here too
String[] mouseUpDests = new String[4];
mouseUpDests[0] = "null";
int mouseUpButton = 0;
Iterator<Transition> transitions = child.getTransitions().values().iterator();
while (transitions.hasNext()) {
Transition transition = transitions.next();
AAction action = transition.getAction();
if (action instanceof ButtonAction) {
ButtonAction bAction = (ButtonAction) action;
MouseButtonState buttonState = bAction.getButton();
MousePressType pressType = bAction.getPressType();
int button = -1;
String destName = getFrameURL(transition.getDestination(), ".html");
if (!MousePressType.Hover.equals(pressType)) {
if (MouseButtonState.Left.equals(buttonState)) {
button = LEFT_MOUSE;
} else if (MouseButtonState.Middle.equals(buttonState)) {
button = MIDDLE_MOUSE;
} else if (MouseButtonState.Right.equals(buttonState)) {
button = RIGHT_MOUSE;
}
/*if (MousePressType.Click.equals(pressType) &&
(button == LEFT_MOUSE))
{
//onAction = "onclick";
// clickDest = "'" + destName + "'";
mouseUpButton = button;
mouseUpDests[mouseUpButton] = "'" + destName + "'";
}
else */
if (MousePressType.Up.equals(pressType) || MousePressType.Click.equals(pressType)) {
//onAction = "onmouseup";
mouseUpButton = button;
mouseUpDests[mouseUpButton] = "'" + destName + "'";
}
// else if (MousePressType.Double.equals(pressType)) {
// //onAction = "ondblclick";
// dblClickButton = button;
// dblClickDests[dblClickButton] = "'" + destName + "'";
// }
// else if (MousePressType.Down.equals(pressType)) {
// onAction = "onmousedown";
// }
}
} else if (action instanceof TapAction) {
TapAction bAction = (TapAction) action;
TapPressType pressType = bAction.getTapPressType();
String destName = getFrameURL(transition.getDestination(), ".html");
if (!TapPressType.Hover.equals(pressType)) {
if (TapPressType.Tap.equals(pressType)) {
// TODO: Behavior is undefined if both a left-click and
// tap transition are created from the same widget!
//onAction = "onclick";
// clickDest = "'" + destName + "'";
mouseUpButton = LEFT_MOUSE;
mouseUpDests[mouseUpButton] = "'" + destName + "'";
}
// else if (TapPressType.Up.equals(pressType)) {
// onAction = "onmouseup";
// }
// else if (TapPressType.DoubleTap.equals(pressType)) {
// //onAction = "ondblclick";
// // TODO see tap
// dblClickButton = LEFT_MOUSE;
// dblClickDests[dblClickButton] = "'" + destName + "'";
// }
// else if (TapPressType.Down.equals(pressType)) {
// //onAction = "onmousedown";
// }
}
}
}
for (int i = 1; i < mouseUpDests.length; i++) {
if (mouseUpDests[i] == null) {
mouseUpDests[i] = "null";
}
// if (dblClickDests[i] == null) {
// dblClickDests[i] = "null";
// }
result += mouseUpDests[i];
if (i < 3) {
result += ", ";
}
}
result += "]";
return result;
}
use of edu.cmu.cs.hcii.cogtool.model.MouseButtonState in project cogtool by cogtool.
the class DesignExportToHTML method parseTransitions.
/**
* Given the transitions from a widget, parse them and return 3 strings:
* first, the name of the destination frame of its hover transition;
* second, the map that defines its single click transitions;
* third, the map that defines its double click transitions.
* (See comments on the javascript functions for how these maps are used.)
*/
protected String[] parseTransitions(IWidget w, boolean checkFocus, int ignoreButton) {
String[] result = new String[2];
result[0] = "null";
result[1] = "[";
// TODO: onmouseup doesn't work for middle clicks...except
// sometimes it does, may be related to focus?
// Always use onmouseup instead of onclick because we need to check
// for double click here too
Iterator<Transition> transitions = w.getTransitions().values().iterator();
// If we are told to ignore transitions from a certain button, check
// if the widget has any transitions defined from that button. If not,
// tell the javascript explicitly not to pop up the "does not help..."
// message if that button is clicked with the IGNORE_LEFT_CLICK string
// flag.
boolean hasIgnoredButtonTransition = false;
while (transitions.hasNext()) {
Transition transition = transitions.next();
AAction action = transition.getAction();
if (action instanceof ButtonAction) {
ButtonAction bAction = (ButtonAction) action;
MouseButtonState buttonState = bAction.getButton();
MousePressType pressType = bAction.getPressType();
int button = -1;
String destName = getFrameURL(transition.getDestination(), ".html");
int modifiers = bAction.getModifiers();
int numClicks = 0;
if (MousePressType.Hover.equals(pressType)) {
result[0] = "'" + destName + "'";
} else {
if (MouseButtonState.Left.equals(buttonState)) {
button = LEFT_MOUSE;
if (checkFocus) {
destName += buildFocusSearch(w, transition.getDestination());
}
} else if (MouseButtonState.Middle.equals(buttonState)) {
button = MIDDLE_MOUSE;
} else if (MouseButtonState.Right.equals(buttonState)) {
button = RIGHT_MOUSE;
}
if (MousePressType.Up.equals(pressType) || MousePressType.Click.equals(pressType)) {
numClicks = 1;
if ((button == ignoreButton) && (modifiers == AAction.NONE)) {
hasIgnoredButtonTransition = true;
}
} else if (MousePressType.Double.equals(pressType)) {
numClicks = 2;
} else if (MousePressType.Triple.equals(pressType)) {
numClicks = 3;
}
if (result[1].length() > 1) {
result[1] += ", ";
}
result[1] += "[" + button + ", " + numClicks + ", " + modifiers + ", '" + destName + "']";
}
} else if (action instanceof TapAction) {
TapAction bAction = (TapAction) action;
TapPressType pressType = bAction.getTapPressType();
String destName = getFrameURL(transition.getDestination(), ".html");
int numClicks = 0;
if (TapPressType.Hover.equals(pressType)) {
result[0] = "'" + destName + "'";
} else {
if (TapPressType.Up.equals(pressType) || TapPressType.Tap.equals(pressType)) {
// TODO: Behavior is undefined if both a left-click and
// tap transition are created from the same widget!
numClicks = 1;
if (ignoreButton == 1) {
hasIgnoredButtonTransition = true;
}
} else // }
if (TapPressType.DoubleTap.equals(pressType)) {
//onAction = "ondblclick";
// TODO see tap
numClicks = 2;
} else if (TapPressType.TripleTap.equals(pressType)) {
// TODO see tap
numClicks = 3;
}
if (result[1].length() > 1) {
result[1] += ", ";
}
result[1] += "[" + LEFT_MOUSE + ", " + numClicks + ", " + AAction.NONE + ", '" + destName + "']";
}
}
}
if (!hasIgnoredButtonTransition) {
// transition already defined
if (result[1].length() > 1) {
result[1] += ", ";
}
result[1] += "[" + ignoreButton + ", 1, 0, " + IGNORE_LEFT_CLICK + "]";
}
result[1] += "]";
return result;
}
use of edu.cmu.cs.hcii.cogtool.model.MouseButtonState in project cogtool by cogtool.
the class ActionPropertySet method layOutMouseComposite.
@Override
public void layOutMouseComposite() {
// Attach mouse button label to 5 from the properties left
FormData data = new FormData();
data.top = new FormAttachment(mouseButtonCombo, 0, SWT.CENTER);
data.left = leftAttachment;
mouseButtonLabel.setLayoutData(data);
// Attach mouse button combo to 5 pixels from the label's bottom
// Attach mouse button combo to 5 from the properties left
// Attach right of combo to end of the properties space
data = new FormData();
data.top = new FormAttachment(0, 5);
data.left = new FormAttachment(mouseButtonLabel, 5, SWT.RIGHT);
data.right = new FormAttachment(100, -5);
mouseButtonCombo.setLayoutData(data);
// Center button action label to 5 below the previous combo
// Attach button action label to 5 pixels from the properties left
data = new FormData();
data.top = new FormAttachment(mouseActionCombo, 0, SWT.CENTER);
data.left = leftAttachment;
mouseActionLabel.setLayoutData(data);
data = new FormData();
// Align button action combo with mouse action label
// Attach right of combo to end of the properties space
data.left = new FormAttachment(mouseButtonCombo, 0, SWT.LEFT);
data.top = new FormAttachment(mouseButtonCombo, 5);
data.right = new FormAttachment(100, -5);
mouseActionCombo.setLayoutData(data);
data = new FormData();
data.left = new FormAttachment(transitionDestinationLabelMouse, 5, SWT.RIGHT);
data.right = new FormAttachment(100, -5);
if (buttonModifierSet == null) {
data.top = new FormAttachment(mouseActionCombo, 5, SWT.BOTTOM);
} else {
data.top = new FormAttachment(buttonModifierSet.FUNCTION, 5, SWT.BOTTOM);
}
transitionSourceNameMouse.setLayoutData(data);
data = new FormData();
data.left = leftAttachment;
data.top = new FormAttachment(transitionSourceNameMouse, 0, SWT.CENTER);
transitionSourceLabelMouse.setLayoutData(data);
data = new FormData();
data.left = leftAttachment;
data.top = new FormAttachment(transitionDestinationNameMouse, 0, SWT.CENTER);
transitionDestinationLabelMouse.setLayoutData(data);
data = new FormData();
data.left = new FormAttachment(transitionDestinationLabelMouse, 5, SWT.RIGHT);
data.right = new FormAttachment(100, -5);
data.top = new FormAttachment(transitionSourceNameMouse, 5, SWT.BOTTOM);
transitionDestinationNameMouse.setLayoutData(data);
SelectionListener setResetListener = new SetResetDefaultsListener(setAsDefaultMouse, restoreDefaultsMouse) {
@Override
protected boolean haveValuesChanged() {
return isMouseChanged(originalProperties);
}
@Override
protected void setDefaults(boolean isReset) {
MousePressType mpt = getMousePressType();
MouseButtonState mbs = (mpt != MousePressType.Hover) ? getMouseButton() : null;
int mods = getMouseModifiers();
setMouseDefaults(mbs, mpt, mods);
}
@Override
protected void resetDefaults() {
resetMouse();
}
};
addDefaultButtons(mouseParms, transitionDestinationNameMouse, setAsDefaultMouse, restoreDefaultsMouse, setResetListener);
}
use of edu.cmu.cs.hcii.cogtool.model.MouseButtonState in project cogtool by cogtool.
the class ActionSet method createMouseComposite.
protected Composite createMouseComposite() {
Composite mouseComp = new Composite(actionSettings, SWT.NONE);
mouseComp.setLayout(new FormLayout());
mouseButtonLabel = new DisplayLabel(mouseComp, SWT.NONE);
mouseButtonLabel.setText(L10N.get("DE.MouseButtonCaption", "Mouse Button") + ":");
// TODO Why is this here rather than in its natural home in the
// overridden method in ActionPropertySet?
transitionSourceLabelMouse = createTransitionSourceLabel(mouseComp);
transitionSourceNameMouse = createTransitionSourceName(mouseComp);
transitionDestinationLabelMouse = createTransitionDestinationLabel(mouseComp);
transitionDestinationNameMouse = createTransitionDestinationName(mouseComp);
mouseButtonCombo = new ComboWithEnableFix(mouseComp, SWT.DROP_DOWN | SWT.READ_ONLY);
for (MouseButtonState element : MouseButtonState.DISPLAY) {
mouseButtonCombo.add(element.toString());
}
mouseButtonCombo.select(0);
mouseButtonCombo.addSelectionListener(widgetActionChange);
mouseActionLabel = new DisplayLabel(mouseComp, SWT.NONE);
mouseActionLabel.setText(L10N.get("DE.ButtonActionCaption", "Action") + ":");
mouseActionCombo = new ComboWithEnableFix(mouseComp, SWT.DROP_DOWN | SWT.READ_ONLY);
for (MousePressType element : MousePressType.DISPLAY) {
mouseActionCombo.add(element.toString());
}
mouseActionCombo.select(0);
mouseActionCombo.addSelectionListener(widgetActionChange);
// then add modifier set for the mouse clicks.
if (DeviceType.Keyboard.isMember(deviceTypes)) {
buttonModifierSet = new ActionModifierSet(mouseActionCombo, widgetActionChange, vertical);
}
return mouseComp;
}
Aggregations