Info

此问题已关闭。 请重新打开它进行编辑或回答。

How to switch between two buttons with callbacks being impoly and imellipse respectively

1 次查看(过去 30 天)
I created two toggle buttons in a figure, one button's callback is impoly and another one is imellipse. I click the impoly button and then the imellipse button. The ideal is that the impoly callback is cancelled and the imellipse is implementing. But how to do that? Usually what I do is to have the third botton to fire an 'ESC' to cancel the clicked button and then move to the button wanted, which is not an elegant way. I tried to debug the matlab's switch between 'zoomin' and 'zoomout'. It seems the switch is dealed within its built-in functions.
Thank you!
  2 个评论
Jun Li
Jun Li 2013-5-29
I think it could be a bug or unsolved issue for MATLAB. The error is 'Error while evaluating figure WindowButtonMotionFcn'. Again I guess is that some context isn't saved when the first callback is interrupted by the second. This includes the callback of WindowButtonMotionFcn. I think this link (<http://www.mathworks.co.uk/matlabcentral/newsreader/view_thread/148650>) could be a similiar question.
Jun Li
Jun Li 2013-5-30
And I cannot play around with the 'Interruptible' and 'BusyAction', as I believe that the impoly and imellipse use 'drawnow' and 'uiwait'. I suggest the Mathworks should properly design their interruption and callbacks mechanism.

回答(2 个)

Image Analyst
Image Analyst 2013-5-28
Why can't you just issue the escape immediately upon entering the callback? Even if you're not in the middle of drawing something are there any bad side effects of issuing an unnecessary escape?
  2 个评论
Jun Li
Jun Li 2013-5-29
It doesn't work. I guess because it's 'a callback in a callback', the matlab does not allow to cancel the previous callback, otherwise the current callback will not be able to find the return interrupt piont.
Image Analyst
Image Analyst 2013-5-29
Call the Mathworks or ask Yair. But what I'd do is to disable the two buttons and just throw up some text with instructions that say to right click or type escape to abort. Then when your code continues, you can recognize that they aborted because the coordinates will not be right, and then you enable the two buttons again.

Kevin
Kevin 2014-9-16
编辑:Kevin 2014-9-16
Somebody was able to solve this problem? Thank you so much in advance!

此问题已关闭。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by