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!