octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Multiple addlistener calls?


From: Rik
Subject: Multiple addlistener calls?
Date: Wed, 29 Jul 2015 11:25:32 -0700

All,

Should it be possible to add the same function multiple times as a listener on a graphics property?

-- Start Code --
octave:1> function mycb (~,~)
> disp ("Executing mycb");
> endfunction

octave:2> h = plot (1:10);

octave:4> addlistener (h, 'color', @mycb)
octave:5> set (h, 'color', 'r')
Executing mycb
octave:6> addlistener (h, 'color', @mycb)
octave:7> set (h, 'color', 'g')
Executing mycb
Executing mycb
octave:8> addlistener (h, 'color', @mycb)
octave:9> set (h, 'color', 'b')
Executing mycb
Executing mycb
Executing mycb
octave:10> dellistener (h, 'color', @mycb)
octave:11> set (h, 'color', 'm')
Executing mycb
Executing mycb
Executing mycb
-- End Code --

It's making things awkward in legend.m where I'm trying to avoid multiple listener assignments.  If the C++ code were to weed these out it would make the m-file simpler.  Otherwise, I have to figure out which new legend objects were part of an existing legend and avoid adding listeners on just those instances.


--Rik


reply via email to

[Prev in Thread] Current Thread [Next in Thread]