GUIDE: gcf windowscrollWheelFcn and gca ButtonDownFcn interaction
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Brian
el 30 de Jul. de 2014
Comentada: Brian
el 30 de Jul. de 2014
Hello, thanks for reading this,
I have a problem at the moment with a interaction of axes ButtonDownFcn and the gcf's windowscrollWheelFcn.
I made a simple gui in GUIDE with two axes, and when I ButtonDownFcn on either axes I can print unique messages. Additionally, when I click on a axes and use the windowscrollWheelFcn, I can perform a callback on the axes (I replot rand). However, when I do the windowscrollWheelFcn the callback to ButtonDownFcn no longer works: I can't reprint the message.
Any ideas? When I reprint, I set the HitTest of the image (not the axes) to off when I replot, but it doesn't help the problem. The windowscrollWheelFcn, however, works just fine, which makes me think its a HitTest issue somewhere that's not being set.
EDIT: I just put the additional command behind the windowscrollWheelFcn:
set(gca,'ButtonDownFcn', @axes1_ButtonDownFcn);
and I was able to use the ButtonDownFcn callback again, but only for one of the unique messages (the ButtonDownFcn I point to out of two possible ButtonDownFcn). Is there a way to preserve the original function passing for ButtonDownFcn when I create the axes?
0 comentarios
Respuesta aceptada
Robert Cumming
el 30 de Jul. de 2014
without seeing the actual code I can only speculate - but it sounds like the ButtonDownFcn is being removed when you replot, this happens by design when the axes nextplot property is 'replace'.
See the example below on how changing the nextplot to be 'add' alters the behaviour (note you need to clear the axes "cla" when you want to draw a new plot.
function test
f = figure;
a1 = axes ( 'parent', f, 'position', [0 0 0.5 0.5], 'ButtonDownFcn', @redrawA1 );
a2 = axes ( 'parent', f, 'position', [0.5 0.5 0.5 0.5], 'ButtonDownFcn', @redrawA2, 'nextplot', 'add' );
end
function redrawA1 ( obj, event )
disp( 'in callback A1' );
plot ( gca, rand(10), rand(10) );
end
function redrawA2 ( obj, event )
cla ( gca )
disp( 'in callback A2' );
plot ( gca, rand(10), rand(10) );
end
3 comentarios
Robert Cumming
el 30 de Jul. de 2014
Change the nextplot property of you axes. Thats what I was demonstrating.
When you re-issue a plot command your callback is being removed (i.e. in your scroll callback you have a plot command -> deleted buttondownfcn callback to the current axes)
Más respuestas (0)
Ver también
Categorías
Más información sobre Graphics Object Identification en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!