scroll(testCase,comp,direction)
performs a scroll gesture, such as a scroll wheel movement, with the pointer located at the
center of the specified component comp. The method mimics a user
scrolling in the specified direction.
Test a vertical scroll gesture on axes whose background color changes based on the scroll direction.
Create a UI figure with axes whose background color changes based on the direction of a vertical scroll. To program the axes behavior, create a window scroll wheel callback for the figure by specifying its WindowScrollWheelFcn callback property. See the code of the callback function changeColor, which is used to change the axes background color based on the scroll direction, at the end of this example.
Test a scroll gesture on the axes in the down direction. The gesture executes the window scroll wheel callback, which sets the axes background color based on the scroll direction.
testCase.scroll(ax,"down")
Test if the axes background color is now green, or [0 1 0]. The test passes.
testCase.verifyEqual(ax.Color,[0 1 0])
Verification passed.
Callback Function
This code shows the callback function used in this example. The function queries the VerticalScrollCount property of event to identify the scroll direction.
function changeColor(src,event)
if event.VerticalScrollCount < 0 % scrolling up
src.Children.Color = "red";
elseif event.VerticalScrollCount > 0 % scrolling down
src.Children.Color = "green";
endend
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.