what event to use in addlistener for a popupmenu

4 Ansichten (letzte 30 Tage)
Yitian Zhang
Yitian Zhang am 29 Aug. 2022
Beantwortet: chrisw23 am 30 Aug. 2022
Hello I have created the following code to do some simple task:
  1. 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.
  2. 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

Antworten (1)

chrisw23
chrisw23 am 30 Aug. 2022
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

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Produkte


Version

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by