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.
Website auswählen
Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .
Sie können auch eine Website aus der folgenden Liste auswählen:
So erhalten Sie die bestmögliche Leistung auf der Website
Wählen Sie für die bestmögliche Website-Leistung die Website für China (auf Chinesisch oder Englisch). Andere landesspezifische Websites von MathWorks sind für Besuche von Ihrem Standort aus nicht optimiert.