Filter löschen
Filter löschen

Throwing errors using NET listeners implemented in a class

2 Ansichten (letzte 30 Tage)
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)

Akzeptierte Antwort

Katherine May
Katherine May am 29 Apr. 2022
Bearbeitet: Katherine May am 29 Apr. 2022
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.

Weitere Antworten (0)

Kategorien

Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange

Produkte


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by