Scrolling and zooming with mouse wheel
Ältere Kommentare anzeigen
Hi,
I'm programming a GUI programmatically (not using GUIDE) and want to scroll a slider to scroll through variables.
The GUI also has an axes which to zoom on request.
I can't use the scrolling of my slider when the zoom is active (or panning, data tip and so on).
Is there a possibility for a workaround or that the zoom only works for the axes?
I managed to scroll the slider by using the current position of the mouse. When the mouse on the slider the scrolling with the mouse wheel is active. It would be nice if this is also possible for the zooming.
This is a simplified codes I use:
function test_figscroll
fig=figure('Position',[200 200 1000 800],'Resize','off','Units','Pixel',...
'Paperunits','centimeters','PaperSize',[30 20],'PaperPosition',[0 0 30 20]);
ax=axes('units','pixel','Position',[70,50,690,680],'parent',fig);
ax.Box='on';
ax.XGrid='on';
ax.YGrid='on';
buttonzoom=uicontrol('Style','togglebutton','Position',[90,765,30,30],'callback',@zooming);
hTempSlide=uicontrol('Style','slider','Position',[800,50,40,550]);
hTempSlide.Min=1;
hTempSlide.Max=10;
hTempSlide.Value=10;
function zooming(~,~)
hz=zoom(ax);
hz.RightClickAction='InverseZoom';
if buttonzoom.Value
hz.Enable='on';
hz.Motion='both';
else
hz.Enable='off';
end
end
function figscroll(~,value)
mousePoint=get(fig,'CurrentPoint');
if mousePoint(1)<840 && mousePoint(1)>800 && mousePoint(2)<600 && mousePoint(2)>50
if value.VerticalScrollCount>0 && hTempSlide.Value>hTempSlide.Min
hTempSlide.Value=hTempSlide.Value-1;
if hTempSlide.Value<hTempSlide.Min
hTempSlide.Value=hTempSlide.Min;
end
elseif value.VerticalScrollCount<0 && hTempSlide.Value<hTempSlide.Max
hTempSlide.Value=hTempSlide.Value+1;
if hTempSlide.Value>hTempSlide.Max
hTempSlide.Value=hTempSlide.Max;
end
end
end
end
end
I'm using Matlab R2015a SP1 as it is the last version with 32 bit compatibility.
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Graphics Object Properties finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
