MATLAB Answers

Adam Kaas

if statement asking if an addlistener() event has occured

Asked by Adam Kaas
on 21 May 2012

Is there a way to write an if statement that says something like:

if % addlistener(handles.Edit1, 'String','PostGet',f) occured %do something end

  0 Comments

Products

No products are associated with this question.

2 Answers

Answer by Sean de Wolski
on 21 May 2012
 Accepted answer

I don't really understand why you would want to do this. The purpose of the listener is to fire when something (some event) happens. Why then do you need an if()? When this something happens, the listener will fire and your if() will happen automagically.

  13 Comments

Adam Kaas
on 22 May 2012

IT WORKS!! Thanks so much guys!

Walter Roberson
on 22 May 2012

Your handles must have been associated with a different figure number I guess.

Sean de Wolski
on 22 May 2012

or improperly GUIDATAed (new verb!). That is why I avoid GUIDATA like the plague.


Answer by Walter Roberson
on 21 May 2012

Have the listener set a variable in an area you can test.

  1 Comment

Adam Kaas
on 21 May 2012

So could I use an expression such as

addlistener(handles.Edit1, 'String', 'PostGet', n=1);

then test my n variable? I tried it and it doesn't like the expression at all and I can't find any documentation why.


Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply today