Why does a callback get executed while clicking the mouse and not while releasing it in MATLAB 7.0 (R14)?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
In MATLAB 6.0 I execute the following lines of code
figure(1);peaks
uimenu(1,'label','2D','callback','view(2);axis equal')
uimenu(1,'label','3D','callback','view(3);axis normal')
In the figure window notice that two tabs '2D' and '3D' get displayed. If you click on the 2D tab, a 2D plot appears in the axes. Click on 3D tab to make a 3D plot appear on the same axes. Mouse release activates the callbacks in this case.
In MATLAB 7.0 I execute the same code. Again in the figure window two tabs '2D' and '3D' appear. Click on the 2D tab to make a 2D plot appear on the axes. Now move the mouse to the 3D plot and notice that we do not have to click on 3D to make a 3D plot appear. Just switching the mouse between 2D and 3D toggles between the 2D and 3D plots in the axes.The mouse position itself activates the callbacks in this case.
Respuesta aceptada
MathWorks Support Team
el 27 de Jun. de 2009
The behavior observed in MATLAB 7.0 is consistent with the way menu items appear in Windows. If one wishes to have callbacks implemented in the way it was done in MATLAB 6.0, one can use the 2D and the 3D items appearing under a single menu. This enables callback activation upon mouse button release. Refer to the example below:
function solution
figure(1);peaks;
g = uimenu('Label','Dimension');
uimenu(g,'Label','2D','Callback',@twodimension);
uimenu(g,'Label','3D','Callback',@threedimension);
function twodimension(hObject, eventdata, handles)
disp('2 d selected')
view(2)
function threedimension(hObject, eventdata, handles)
disp('3 d selected')
view(3)
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Interactive Control and Callbacks 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!