pop up in address_book GUI demo with .mat file
古いコメントを表示
hi all...
Could anyone show me how to use pop up menu in address_book gui demo rather than use push button menu??
thanks
回答 (3 件)
per isakson
2012 年 5 月 27 日
0 投票
15 件のコメント
Luhur
2012 年 5 月 27 日
Walter Roberson
2012 年 5 月 27 日
Using a pop-up menu is not different when one is using a .mat file.
Luhur
2012 年 5 月 27 日
Walter Roberson
2012 年 5 月 27 日
I do not have access to MATLAB today, so I cannot examine what they have done in that particular demo.
When you wrote "its different when using .mat file", did you mean that it is different when using GUIDE? The main difference when using GUIDE is that GUIDE likes to name the functions according to what kind of uicontrol is being used. The change at the MATLAB level between a pushbutton and a pop-up is very small, just set the uicontrol 'style' property to 'popup'
Luhur
2012 年 5 月 27 日
Walter Roberson
2012 年 5 月 27 日
It would be much easier if you were to ask specific questions.
Luhur
2012 年 5 月 27 日
Walter Roberson
2012 年 5 月 27 日
To adapt, use this routine as the callback for the popup menu, but do not pass any string in to it.
Instead, at the top,
menuval = get(hObject, 'Value');
menustrings = cellstr( get(hObject, 'String') );
str = menustrings{menuval};
And that's it for the code changes, provided that you set the popup menu to have entries 'Prev' and 'Next'
Luhur
2012 年 5 月 28 日
Walter Roberson
2012 年 5 月 28 日
function Prev_Next_Callback(hObject, eventdata, handles) %CHANGE
% hObject handle to Prev_Next (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
menuval = get(hObject, 'Value'); %NEW
menustrings = cellstr( get(hObject, 'String') ); %NEW
str = menustrings{menuval}; %NEW
% Get the index pointer and the addresses
index = handles.Index;
Addresses = handles.Addresses;
% Depending on whether Prev or Next was clicked change the display
switch str
case 'Prev'
% Decrease the index by one
i = index - 1;
[etc to the rest of the routine]
And have this routine be the callback for your popup menu.
Luhur
2012 年 5 月 28 日
Walter Roberson
2012 年 5 月 28 日
Use the property editor on that popup menu, and remove the comma and the 'Next' from the calling sequence.
Luhur
2012 年 5 月 28 日
Luhur
2012 年 5 月 28 日
Luhur
2012 年 5 月 29 日
カテゴリ
ヘルプ センター および File Exchange で Argument Definitions についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!