Main Content

doublePress

R2026b

Class: matlab.uitest.TestCase
Namespace: matlab.uitest

Perform double-press gesture on UI component

Since R2026b

Description

doublePress(testCase,comp,element) performs a double-press gesture, such as a mouse double-click, on the specified element of the UI component comp.

example

Input Arguments

expand all

Test case, specified as a matlab.uitest.TestCase object.

Component under test, specified as a ListBox object. You can create a list box using the uilistbox function.

Component element to double-press, specified as a positive integer scalar, string scalar, or character vector. For a list box, you can specify element as the index or text of a list box item.

Example: 1 (first list box item)

Example: "Blue" (list box item containing the text "Blue")

Attributes

Sealedtrue

To learn about attributes of methods, see Method Attributes.

Examples

expand all

Create a list box in a UI figure. Set the DoubleClickedFcn callback property of the list box to display a message when a list box item is double-clicked.

fig = uifigure;
lb = uilistbox(fig, ...
    Items=["Red" "Green" "Blue"], ...
    DoubleClickedFcn=@(src,~) disp(src.Value + " item double-clicked!"));

Create a test case for interactive testing.

testCase = matlab.uitest.TestCase.forInteractiveUse;

Double-press the first list box item. A blue dot representing the programmatic double-press gesture briefly appears at the center of the item. The gesture executes the DoubleClickedFcn callback, which displays a message in the Command Window.

testCase.doublePress(lb,1)
Red item double-clicked!

Now, double-press the last list box item using its text.

testCase.doublePress(lb,"Blue")
Blue item double-clicked!

Version History

Introduced in R2026b