2012-08-01 35 views
0

我在我的matlab gui中有一個名爲listBitDepth的popupmenu。matlab popupmenu回調從未調用

我使用

bitDepthStr{1}= ' auto detect '; mapBitDepthToListIndex(1) = 0; 
bitDepthStr{2}= ' 8 bit (256)'; mapBitDepthToListIndex(2) = 8; 
bitDepthStr{3}= '10 bit (1024)'; mapBitDepthToListIndex(3) = 10; 
bitDepthStr{4}= '12 bit (4096)'; mapBitDepthToListIndex(4) = 12; 
bitDepthStr{5}= '14 bit (16384)'; mapBitDepthToListIndex(5) = 14; 
bitDepthStr{6}= '16 bit (65536)'; mapBitDepthToListIndex(6) = 16; 
set(handles.listBitDepth,'String',bitDepthStr); 
set(handles.listBitDepth,'value',1); 

其中工程值填充它。

而且我有一個回調函數

function listBitDepth_Callback(hObject, eventdata, handles) 
val = get(hObject,'Value') 
... 

它但是如果我從彈出菜單中選擇列表中的項目不叫。

爲什麼?

+0

你使用指南創建您的GUI?是否有通過屬性檢查器指定的回調(或通過代碼添加)? – grantnz 2012-08-01 15:09:40

+0

我使用所有回調函數的指南。如果它們不存在,我將它們與屬性檢查器一起添加。 – 2012-08-02 09:31:43

回答

1

如果在代碼行設置後運行到斷點後執行以下操作,您會得到什麼(handles.listBitDepth,'value',1); ?

get(handles.listBitDepth,'callback') 

你應該看到:

ANS =

@(hObject,eventdata)popuptest('listBitDepth_Callback',hObject,eventdata,guidata(hObject)) 
+0

的確,這就是我所看到的。 – 2012-08-06 08:20:58

+0

現在有效。我改變了他在函數中的代碼,不知何故,他回調現在被稱爲「我不明白爲什麼」。 – 2012-08-07 07:23:20