Undocumented Secrets of MATLAB
®
-Java Programming498
well-known MATLAB practice, although we shall see that it uses an undocumented callback
and functionality.
A possible alternative is to set a PostSet handle.listener on the relevant object property (see
Appendix B). This approach is entirely undocumented and not well known. Interested readers
can try this approach, rather than the callbacks approach that I have taken.
The solution involved getting the Command-Window reference, then setting its
CaretUpdateCallback. This callback is red whenever the desktop text is modied, which is
an event we trap to replace the displayed prompt:
% Get the reference handle to the Command Window text area
jDesktop = com.mathworks.mde.desk.MLDesktop.getInstance; ...