MATLAB: Pushbutton activated by Enter(return) key

guimatlab guipushbutton

Hi,
I would like to ask you why doesn't work when I call funtion pushbutton1_Callback inside pushbutton1_KeyPressFcn. I have besidde other things buttons where I want them to react to Enter key when user Tabs to it (+ ofcourse when user just click at it). I thought that the simplest way would be to call pushbutton1_Callback in pushbutton1_KeyPressFcn,but obviously not…how caan I do this feature ?
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