Clear Filters
Clear Filters

Error using rotate3d and context menu in App Designer. Event 'ContextMenuOpening' is not defined for class 'matlab.gr​aphics.Gra​phicsPlace​holder'.

1 view (last 30 days)
I have an application converted from GUIDE to App Designer. It uses an external library that performs various calculations and data is passed back and forth. In the app a 3D model is displayed on UIAxes and there is a callback function that uses camlight to move the lighting as you rotate the model. As the object is moved the lights are repositioned, and the rotation property is re-enabled. Among other typical UI objects in the app, there is a listbox with a context menu that is used to run various functions based on the options selected in the listbox.
When I open the context menu on the listbox and rotate3d has been enabled using r.Enable = 'on' in the code or by clicking the rotation icon on the figure, the following error is generated:
Error in executing callback registered with ViewModel: Event 'ContextMenuOpening' is not defined for class 'matlab.graphics.GraphicsPlaceholder'
It seems that using the rotate3d object to enable various options causes the problem:
surf(app.UIAxes, peaks);
r = rotate3d(app.UIAxes);
r.ActionPostCallback = {@app.mycallback, app}; % I want to use this property. It alone doesn't error
r.Enable = "on"; % This generates the error
I'm not sure why, but using the function this way doesn't generate the error message.
surf(app.UIAxes, peaks);
rotate3d(app.UIAxes, "on")
% Is something like this possible?
% rotate3d(app.UIAxes, "on", "ActionPostCallback", {@app.mycallback, app})
However, I want to use the ActionPostCallback property. Why might the rotate3d object cause this error when opening the context menu?
I believe I've reduced the error down to the minimum pieces causing the problem and have a working example attached.
Steps to reproduce:
  1. With line 31 commented out and lines 35-37 uncommented, run the application
  2. Right click on the listbox to generate the error
  3. Go back to code, comment out lines 35-37, uncomment line 31, and rerun the application
  4. Right click on the listbox and see that no error is generated
Note: you can invoke the callback function in step 2 by rotating the figure.
Thanks for any help

Accepted Answer

ts
ts on 27 Mar 2024
Based on communication with Mathworks support, this error is caused by a bug in the internal Matlab function "modeWindowButtonDownFcn." I've attached a workaround from the support team that fixes this issue.
Replace the "modeWindowButtonDownFcn.m" file in the folder \matlab\toolbox\matlab\uitools\+matlab\+uitools\+internal\@uimode with the m file attached.
It was mentioned that this bug will be fixed in a later release.

More Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Products


Release

R2023b

Community Treasure Hunt

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

Start Hunting!