MATLAB: Is there a ButtonUpFcn exist for Push Buttons in MATLAB 7.8 (R2009a)

MATLAB

Figures have a WindowButtonDownFcn and a WindowButtonUpFcn that allow GUI developers to detect when a GUI user is pressing the mouse button versus when the GUI user has lifted their finger off their mouse button.
I want to know if there is an equivalent function for PushButtons.

Best Answer

The functionality to detect when a GUI user is actively pressing a Pushbutton versus when a user has lifted their finger off the mouse button and is no longer pushing the Pushbutton is not available in MATLAB 7.8 (R2009a).
As a workaround, use a Toggle Button with the following callback:
% --- Executes on button press in togglebutton1.
function togglebutton1_Callback(hObject, eventdata, handles)
% hObject handle to togglebutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of togglebutton1
isDown = get(hObject,'Value');
if isDown
%...enter the code you wish to execute while the toggle button is depressed.
else
%...enter the code you wish to execute while the toggle button is no longer % depressed.
end