JK from the Matlab Support Team provided a solution. Before the origButtonMotionCB definition above, he suggested adding the following code:
if isempty(get(hFig, 'WindowButtonMotionFcn'))
set(hFig, 'WindowButtonMotionFcn',@(~,~) deal());
end
He provided two reasons why the "impoly" function was not showing the animated lines:
================================
1. The "impoly" function uses the figure's "WindowButtonMotionFcn" callback to handle animating the line as you move the mouse around. Right now, the "WindowButtonUpFcn" gets rid of any existing callbacks in "WindoButtonMotionFcn". Although this allows for "hline" to stop moving when the mouse is released, it also removes the "impoly" function's callback as you release the mouse.
2. The "CurrentPoint" property is used to determine where the mouse is located in the axes data space. However, this property is only ever updated on mouse clicks or when the figure's WindowButtonMotionFcn is not empty. Because of this, the animation for "impoly" will work only if "WindowButtonMotionFcn" is not empty. Setting the "WindowButtonMotionFcn" to something that is not empty but still doesn't really do anything (e.g. deal()) could resolve this issue.
To deal with these issues, the following work around will work if using "drawpolygon" as opposed to "impoly".
The modified code avoids setting an empty callback in WindowButtonMotionFcn during drawing.
================================
The solution does work for drawpolygon and drawpolyline. It still does not work for impoly. But I should probably update my application anyway... :-)
Mega thanks to JK at Matlab Support for the solution!
Best Answer