0
我試圖創建一個相當於一個程序之間的交互如下:鍵盤迴調和鼠標回調
1,按空格
2 - 「禁用」的KeyPressFcn功能
3播放聲音
4-使鼠標操作
5-聲音將被播放
6- 「使能」 再KeyPressFcn功能
7回1
function figure1_KeyPressFcn(hObject, eventdata, handles)
switch eventdata.Key
case 'space'
set(hObject, 'KeyPressFcn', [])
soundsc(y,Fs);
otherwise
disp('error');
end
end
function pushbutton1_Callback(hObject, eventdata, handles)
soundsc(y,Fs);
set(hObject, 'KeyPressFcn', {@figure1_KeyPressFcn, handles})
guidata(hObject, handles);
end
步驟6不起作用,所以問題是,如何從一個mousecallback設置hObject爲KeyPressFcn?