필터 지우기
필터 지우기

Throwing errors using NET listeners implemented in a class

조회 수: 2 (최근 30일)
Katherine May
Katherine May 2022년 4월 28일
편집: Katherine May 2022년 4월 29일
I'm implementing a .NET listener to run Matlab callbacks on a .NET application whenever certain buttons are clicked. This is done in a class, based on the instructions here:
These callbacks are supposed to throw errors as popups if the input is incorrect, and they use the error() function to do this. However, when I run the callbacks using the listeners, anything thrown using the error() function gets downgraded to a warning, and it prints in the Command Window instead of showing as a popup. It looks like this:
Warning: Error occurred while executing the listener callback for event Click defined for class System.Windows.Forms.Button:
Error using GetCanConfigForm/btnCreateSimFunc_Listener (line 75)
Please enter the CAN Rx Msg function name to create.
I can catch these "warnings" using try-catch & rethrow the errors using errordlg(). This does make a popup, but the OK buttons on the errordlg popups do nothing instead of closing the popup as expected. The X in the top right corner does work to close the popup.
How do I either force error() to throw popups in this context, or fix the errordlg() OK button to close the popup?
(Using Matlab R2019a)

채택된 답변

Katherine May
Katherine May 2022년 4월 29일
편집: Katherine May 2022년 4월 29일
I found a fix for the errordlg OK button - I needed to add waitfor():
f = errordlg(errtxt, 'CAN Rx Msg Error');
waitfor(f);
uiwait(f) also works.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by