Java Convenience API

Note: The Java Convenience API is only available in Squish for Java editions.

Supporting unusual object graphs/hierarchies.

The Java Extension API for Custom Widgets explains how extend Squish to support non-standard parent-child relationships in custom Java types.

Java Convenience API Functions

activateAction

Activates a JFace Action object.

activateItem

Activates a menu item.

chooseColor

Invokes the platform's native color chooser dialog.

chooseDirectory

Invokes the platform's native directory chooser dialog.

chooseFile

Invokes the platform's native file chooser dialog.

clickButton

Clicks a button.

clickItem

Clicks on an item in a View.

clickTab

Clicks on a named tab in a tab widget.

clickTreeHandle

Expand/Collapse a node in a tree view (Swing or SWT).

closeMessageBox

Closes a message box dialog.

closeWindow

Closes a window.

collapse

Collapse a tree item (Swing or SWT).

doubleClick

Performs a mouse double-click.

doubleClickItem

Performs a double-click on an item in a view widget.

dragAndDrop

Performs a drag and drop operation.

dragItemBy

Performs a drag operation.

dropOn

Performs a drop after a call to startDrag.

expand

Expand a tree item (Swing or SWT).

gesture

Plays a gesture.

installEventHandler

Installs a global event handler.

mouseClick

Clicks the mouse on a specified widget/position.

mouseDrag

Performs a mouse drag operation.

mouseWheel

Moves the mouse scroll wheel.

nativeMouseClick

Clicks the mouse at a specific position (AWT/Swing).

readGesture

Returns a GestureBuilder object after reading data from a gesture file.

setValue

Sets the value of a slider or scrollbar.

startDrag

Initiates a drag operation on a specified widget.

type

Types text into an input widget.

Java Convenience API Classes/Objects

GestureBuilder Class

Object for storing touch stroke information.

JavaArray class

Native Java Array

lastAlert object

An object containing properties about the last SWT dialog.

Java Convenience Function Parameters

Some of the Java convenience functions can take a modifierState argument which indicates which special keys are pressed at the time of a mouse click. And some of the functions can also take a button argument which indicates which mouse button was clicked.

The modifierState values are different for AWT/Swing/JavaFX and for SWT. The modifier states don't have an enumeration so you must use the values from the following table that are relevant to the GUI toolkit.

ModifierAWT/Swing/JavaFXValueSWTValue
No modifier00
Shiftjava.awt.Event.SHIFT_MASK1org.eclipse.swt.SWT.SHIFT131072
Controljava.awt.Event.CTRL_MASK2org.eclipse.swt.SWT.CTRL262144
Metajava.awt.Event.META_MASK4
Altjava.awt.Event.ALT_MASK8org.eclipse.swt.SWT.ALT65536
Commandorg.eclipse.swt.SWT.COMMAND4194304

If more than one is used they must be OR-d together, for example, for Shift and Control use 1|2 for AWT/Swing/JavaFX, and 131072|262144 for SWT.

The button can be any one of the following:

Button SpecifierInformation
Button.NoButtonUsually: Make target visible and move mouse, but do not click.
Button.Button1Left mouse button
Button.Button2Middle mouse button
Button.Button3Right mouse button

The form shown above works for Python and JavaScript. For Perl use this: Button::Button1, etc. For Ruby use this: Button::BUTTON1, etc. For Tcl use this: enum Button Button1, etc.

Java Synthetic Properties

In addition to the public Java class fields, and synthetic properties generated from get* and is* functions, Squish provides some additional Synthetic Properties to make it easier to identify objects. (See Defining Property Sets for more details.)

These properties can only be used with the object name. And are not visible in the object properties list.

PropertyTypeDescription
aboveWidgetObjectHolds the object above this widget in the same logical parent Container or Composite. This should be used for objects that don't have a caption but often come with an accompanying widget. For example, edit boxes have no caption but might have a label above them.
arrowDirectionStringHolds the direction of SWT buttons that have the arrow style enabled.
buttonTypeStringHolds the type of SWT buttons. This property is useful for identifying buttons with arrows.
captionStringHolds the object's title, caption, or text, if this object typically has such text to display.
containerObjectHolds the parent Container or Composite that contains this object. These are typically tab pages or the menu bar.
firstItemTextStringHolds the first text to be found for child SWT ToolItem objects. If no text is found, then the tooltip text is used. This property's value could be the empty string if no text is found and no tooltip text is set.
firstTabCaptionStringHolds the caption of the first CTabItem of a CTabFolder. This property's value could be the empty string if no text is found.
leftWidgetObjectHolds the object to the left of this widget in the same logical parent Container or Composite. This should be used for objects that don't have a caption but often come with an accompanying widget. For example, edit boxes have no caption but often have a label on their left.
menuStyleStringHolds the style of SWT menu—this indicates whether the menu is a menu bar, a popup menu, or a pull-down menu.
typeStringHolds the object's class name—but with any periods in the name replaced with underscores.
windowObjectHolds the top-level window that contains this object.

© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners.
The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation.
Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.

Search Results