How to make popup menu work with left mouse click in matlab GUI?
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Gopinath Karuppannan
el 18 de Ag. de 2021
Comentada: Gopinath Karuppannan
el 19 de Ag. de 2021
Hi
I am using the Matlab Guide tool for creation of GUI. I have created a pop-up menu in Guide tool and listed a 40 set of strings in the dropdown list in codes.
For eg:
A={'hi','bye'};set(handles.popupmenu_1,'string',string(A));
I have used the above code in the popupmenu_1 callback function. After I select the "hi" in the drop down list, the "bye" is displayed. I want to display all strings (hi & bye) once i made left mouse selection in the popup menu.
Even i have tried with "Buttondownfunction", there also i have a constraint that to prior selection of rightclick on the mouse button.
can someone suggest me how to do the left mouse selection displays all set of strings in the popmenu at very first time itself?
Pls let me know if need clarifications.
0 comentarios
Respuesta aceptada
Image Analyst
el 18 de Ag. de 2021
Generally you'd list all 40 items to fill up the popup either in the String property of the popup in GUIDE, or you'd assign them and send them to the popup in your app's OpeningFcn() function. It's very strange to alter the popup contents in the callback itself, though it can be done.
You didn't say how you wanted the list of items to be "displayed". Do you want them in a string called txtPopup on the GUI?
handles.txtPopup.String = handles.popupmenu1.String;
Do you want to print them out to the command window?
popupStrings = handles.popupmenu1.String;
for k = 1 : numel(popupStrings)
fprintf('Item #%d is %s\n', k, popupStrings{k});
end
I don't believe you need to use Buttondownfunction at all.
3 comentarios
Image Analyst
el 18 de Ag. de 2021
In popup1's callback, you can get the strings somehow that you want to load into popup2. You don't need to do it in popup2's callback. Like if popup1 had a,b,c and popup2 had 1,2,3, and if the user picked b from popup1 you want popup 2 to be 400,500,600,700, you could set the popup2 string in popup1's callback, not popup2's callback. So callback 1 would look like
function popup1_Callback(hObject, event, handles)
if handles.popup1.Value == 2 % User selected second item 'b' from popup #1
% Assign strings in popup2.
handles.popup2.String = {'400', '500', '600', '700'};
end
Más respuestas (0)
Ver también
Categorías
Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!