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 clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window.
Web browsers do not support MATLAB commands.
Seleccione un país/idioma
Seleccione un país/idioma para obtener contenido traducido, si está disponible, y ver eventos y ofertas de productos y servicios locales. Según su ubicación geográfica, recomendamos que seleccione: .
También puede seleccionar uno de estos países/idiomas:
Cómo obtener el mejor rendimiento
Seleccione China (en idioma chino o inglés) para obtener el mejor rendimiento. Los sitios web de otros países no están optimizados para ser accedidos desde su ubicación geográfica.