How to fix this Error? __ No constructor 'handle.listener' with matching signature found.

14 views (last 30 days)
I have been getting the following error:
No constructor 'handle.listener' with matching
signature found.
Error in ut_subplot>ut_createListeners (line
427)
handle.listener(axlisth,findprop(axlisth(1),'OuterPosition'),
...
Error in ut_subplot>ut_addAxesToGrid (line 464)
ut_createListeners(p,handle(list));
Error in ut_subplot (line 398)
ut_addAxesToGrid(ax,nrows,ncols,row,col,inset);
Error in meo_plot (line 43)
ut_subplot(1,2,1);
Error in meofis_optimize (line 198)
meo_plot(new_pop, meo);
Error in meofis_batch (line 103)
meofis_optimize();
I am using MATLAB 2019a. The code isn't mine and is supposed to be from 2007. The code stops in the middle of drawing a graph in a gui.
The whole line where is stops -- including line 427 -- is:
list = [...
handle.listener(axlisth,findprop(axlisth(1),'OuterPosition'), ...
'PropertyPostSet',@ut_axesMoved); % <<---- PROBLEM LINE
handle.listener(axlisth,findprop(axlisth(1),'ActivePositionProperty'), ...
'PropertyPreSet',@ut_axesMoved);
handle.listener(axlisth,findprop(axlisth(1),'Parent'), ...
'PropertyPreSet',@ut_axesMoved);
handle.listener(axlisth,'AxisInvalidEvent',{@subplotlayoutInvalid,p});
handle.listener(handle(fig),'FigureUpdateEvent',{@subplotlayout,p})];
I did try the brute force solution of just commenting out the problem line, but the same type of error just showed up with the line right after it. Any help would be most welcome.
I have found this Ask/Answer here, but either I ddin't understant it or it isn't quite the same problem; I tried changing the names of the functions I was using in case they were the same as some that MATLAB uses, but I still got the same error.
Sadly, this question for a very similar error didn't get a reply:
  4 Comments
Anne Davenport
Anne Davenport on 13 Sep 2024
A little more inforamtion .....
I get the same error (No constructor 'handle.listener' with matching signature found.) when I try out any of the following lines.
bbb = handle.listener(axlisth,findprop(axlisth(1),'OuterPosition'), PropertyPostSet',@ut_axesMoved);
ccc = handle.listener(axlisth,findprop(axlisth(1),'ActivePositionProperty'), 'PropertyPreSet',@ut_axesMoved);
ddd = handle.listener(axlisth,findprop(axlisth(1),'Parent'), 'PropertyPreSet',@ut_axesMoved);
eee = handle.listener(axlisth,'AxisInvalidEvent',{@subplotlayoutInvalid,p});
fff = handle.listener(handle(fig),'FigureUpdateEvent',{@subplotlayout,p});
I do not get an error for this line:
aaa = findprop(axlisth(1),'OuterPosition');
Mario Malic
Mario Malic on 15 Sep 2024
So, all these lines of code are about assigning the function that will run when user interacts with the GUI. Those lines with errors that you see, is what MATLAB does if user panned or resized axes, which may not be important. If you really want to get that app working, I believe, "easiest" way is to make it yourself on the latest version.
These errors, may happen because these UI components (subplots, axes) worked differently 15 years ago.
Have you tried the link from the file exchange?

Sign in to comment.

Answers (2)

Walter Roberson
Walter Roberson on 15 Sep 2024
Try changing it to
list = [...
listener(axlisth,findprop(axlisth(1),'OuterPosition'), ...
'PropertyPostSet',@ut_axesMoved); % <<---- PROBLEM LINE
listener(axlisth,findprop(axlisth(1),'ActivePositionProperty'), ...
'PropertyPreSet',@ut_axesMoved);
listener(axlisth,findprop(axlisth(1),'Parent'), ...
'PropertyPreSet',@ut_axesMoved);
listener(axlisth,'AxisInvalidEvent',{@subplotlayoutInvalid,p});
listener(handle(fig),'FigureUpdateEvent',{@subplotlayout,p})];

Anne Davenport
Anne Davenport on 16 Sep 2024
I tried these lines:
list = [...
listener(axlisth,findprop(axlisth(1),'OuterPosition'), ...
'PropertyPostSet',@ut_axesMoved); % <<---- PROBLEM LINE
listener(axlisth,findprop(axlisth(1),'ActivePositionProperty'), ...
'PropertyPreSet',@ut_axesMoved);
listener(axlisth,findprop(axlisth(1),'Parent'), ...
'PropertyPreSet',@ut_axesMoved);
listener(axlisth,'AxisInvalidEvent',{@subplotlayoutInvalid,p});
listener(handle(fig),'FigureUpdateEvent',{@subplotlayout,p})];
But it just gives me a different error:
Error using matlab.graphics.axis.Axes/listener
Event 'PropertyPostSet' is not defined for
class 'matlab.graphics.axis.Axes'.
This error makes me really wonder if the GUI code is just too old to run, if PropertyPostSet is not defined. But I wonder what the updated code would be?
  3 Comments
Anne Davenport
Anne Davenport on 19 Sep 2024
I did look at the link. Helpful, but I'm still getting an error. I tried replacing the original problem line:
list = [...
handle.listener(axlisth,findprop(axlisth(1),'OuterPosition'), ...
'PropertyPostSet',@ut_axesMoved);
handle.listener(axlisth,findprop(axlisth(1),'ActivePositionProperty'), ...
'PropertyPreSet',@ut_axesMoved);
handle.listener(axlisth,findprop(axlisth(1),'Parent'), ...
'PropertyPreSet',@ut_axesMoved);
handle.listener(axlisth,'AxisInvalidEvent',{@subplotlayoutInvalid,p});
handle.listener(handle(fig),'FigureUpdateEvent',{@subplotlayout,p}) ];
With new lines based on what I read:
aval = addlistener(axlisth, 'OuterPosition','PostSet',@ut_axesMoved);
bval = addlistener(axlisth, 'OuterPosition','PreSet',@ut_axesMoved);
cval = addlistener(axlisth, 'OuterPosition','PreSet',@ut_axesMoved);
dval = addlistener(axlisth, 'AxisInvalidEvent',{@subplotlayoutInvalid,p}); %<-- CRASHES HERE
eval = addlistener(handle(fig),'FigureUpdateEvent',{@subplotlayout,p});
list = [ aval, bval, cval, dval, eval ];
.... and I get the error:
No method 'addlistener' with matching
signature found for class
'matlab.graphics.axis.Axes'.
I need to read the addlister documentation again: https://www.mathworks.com/help/matlab/ref/handle.addlistener.html
So, I'm still picking at this old-code error.
Walter Roberson
Walter Roberson on 19 Sep 2024
Are you sure you are using R2019a ?
axlisth = axes();
aval = addlistener(axlisth, 'OuterPosition','PostSet',@ut_axesMoved);
works fine for me in R2019a.
(axlisth will be class 'matlab.graphics.axis.Axes')

Sign in to comment.

Categories

Find more on Graphics Performance in Help Center and File Exchange

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!