MATLAB: Does the GINPUT function within MATLAB 7.0 (R14) return a wrong answer for the BUTTON output argument

buttonfigureginputMATLABpatchr14selectiontypewrong

To reproduce this behavior, execute the following function.
function mytest
line
flag = true;
while flag
[zx, zy, button] = ginput(1);
button
if (button==3) %right button is clicked -> stop
flag = false;
end
end
close
First, click the left mouse button.
You will see that a "1" is correctly returned indicating a left button click.
Then, click the right mouse button. You will see that a "3" is correctly returned indicating a right button click, and the code will close the figure.
Then, execute the function again, and click the left mouse button. You will see that a "2" is incorrectly returned.

Best Answer

This bug has been fixed for Release 14 SP1 (R14SP1). For previous releases, please read below for any possible workarounds:
This issue has been verified as a bug in MATLAB 7.0 (R14) in the way the "SelectionType" property of a figure is set after a mouse button click. This only occurs when a button is clicked on a figure, that figure is closed, then another figure has been opened.
Currently, to workaround this issue, download and install one of the following platform-specific patches:
For Windows:
hg_patch_06292004_win32.zip
For Linux:
hg_patch_06292004_glnx86.zip
For Solaris:
hg_patch_06292004_sol2.zip
Links to these patches can be found the Resolution Documents section at the bottom of this page
Instructions for installing the patch:
1) Download and save the ZIP-file for the appropriate platform.
2) Within the directory "<matlabroot>/bin/<platform>", where [matlabroot] is the directory returned from the MATLABROOT command, and [platform] is the directory for the appropriate platform, rename the libuij.dll/libuij.so and libuij.csf files to libuij.dll/libuij.so.old and libuij.csf.old, respectively.
3) Within the directory "<matlabroot>/java/jar", rename hg.jar to hg.jar.old.
4) Close any existing instance of MATLAB. Open the ZIP-file patch and extract the files to the MATLAB root directory.
Note that if you do not rename the above specified files, they will be overwritten by the patch.