what event to use in addlistener for a popupmenu
2 次查看(过去 30 天)
显示 更早的评论
Hello I have created the following code to do some simple task:
- Using the slider. The addlistener will detect the change of value on the slider, and plot a point in makeplot_filter function, with x and y value equal to the slider value.
- I want to do the same thing with the popup menu (currently commented). There are four values in the dropdown menu, 1, 2, 3, 4. When a value is selected from the dropdown menu, I would like to have another point added, with x and y value equal to the selected value.
Right now I don't know what event I should listen to for this popup menu. I would like to know where in the help documentation I can find all the available event names for pop up menu.
clear all
close all
clc
figure('Name','Filtered image','NumberTitle','off','units','normalized','outerposition',[0.5 0.5 0.5 0.5])
hold on
h = uicontrol('style','slider','units','normalized','position',[0.01 0.85 0.2 0.05],'Min',0.2,'Max',5,'Value',1);
addlistener(h,'ContinuousValueChange',@(hObject,event) makeplot_filter(hObject,event));
% h = uicontrol('style','popupmenu','string',{'1','2','3','4'},'units','normalized','position',[0.01 0.85 0.2 0.05]);
% addlistener(h,'PropertyAdded',@(hObject,event) makeplot_filter(hObject,event));
function makeplot_filter(hObject,event)
hObject.Value
plot(hObject.Value,hObject.Value,'r*')
end
0 个评论
回答(1 个)
chrisw23
2022-8-30
h2 = uicontrol('style','popupmenu','string',{'1','2','3','4'},'units','normalized','position',[0.01 0.85 0.2 0.05]);
h2.Callback = @makeplot_filter;
here's the link to the Matlab doc
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!