MATLAB: How to make buttuns react to enter/return

guiguidematlab guipushbutton

Hi,
I am starting to be slightly irritated by buttons…I can I make a button to react to enter/retun key when I press it when I tab on it ?? I can't find a good functioning solution anywhere. Why for example a questdlg have that function and ordinary buttons dont ??
Please help 🙂
Thanks, Peter

Best Answer

Solution was simple and enough elegant for me...
.
function pushbutton1_KeyPressFcn(hObject, eventdata, handles)
key = get(gcf,'CurrentKey');
if(strcmp (key , 'return'))
pushbutton1_Callback(hObject, eventdata, handles)
end
function pushbutton1_Callback(hObject, eventdata, handles)
%code to be executed