deactivate ButtonDownFcn ? stupid question

Hey Guys,
stupid Question: I have created a function(pushbutton) with the ButtonDownFcn to work with my Plot. Its task is to zoom in everytime i click on the plot. Now is there a way, to deactivate the ButtonDownFcn ? so i can click on a plot without triggering the fcn ?

 Akzeptierte Antwort

Joakim Magnusson
Joakim Magnusson am 11 Aug. 2014

0 Stimmen

Maybe you can have for example a radio button. In your buttonDownFcn you can have an if statement to check if the radiobutton is activated or not. If it's not activated you will zoom, and if it is activated you won't zoom.

4 Kommentare

Max Müller
Max Müller am 11 Aug. 2014
if the ButtonDownfcn is set....its set
Iain
Iain am 11 Aug. 2014
Or you can have another button which changes the function that gets called by the button whose behaviour you want to change.
Or you may be able to use the eventdata to change what you do - though you'll need to do some tests to find out what happens when you, say, hold control, when you click.
Max Müller
Max Müller am 11 Aug. 2014
well u were right
Andy L
Andy L am 11 Aug. 2014
Bearbeitet: Andy L am 11 Aug. 2014
I like joakim's solution. You can then use the zoom property on each radiobutton click.
%%callback to radio button Zoom on
% Turn off other radiobutton
zoom on; % Turn Zoom On.
zoom reset; % Set axis for zoom out.
%%callback to radio button zoom off.
% Turn off other radiobutton
zoom out; % Zoom out to "zoom reset" axis.
zoom off; % Turn zoom off.
This eliminates the need for a push button.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Adam
Adam am 11 Aug. 2014

2 Stimmen

Can you not just turn your push button into a toggle and have it set ButtonDownFcn to [] if it is currently set to whatever you usually set it to?

1 Kommentar

this works as well
if isempty(findobj('tag','ZoomedPlot')) == 1
else
close ZoomedPlot;
end
Data = findobj('type','axes');
set(Data,'buttondownfcn',@ClickToZoom);
function ClickToZoom (gcbo,evendata,handles)
Data = gca;
ZoomedPlot = figure;
newData = copyobj(Data,ZoomedPlot);
set(newData,'Position', [0.1 0.1 0.85 0.85]);

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Interactive Control and Callbacks 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!

Translated by