extra uitoolbar in GUI figure (R2023b)

Just download the R2023b. In the figure I have developped (using GUIDE), there is a full toolbar that I did not create appears as a second toolbar.
I read through the release note and did not find anything about it.
Is it normal? What is the correct way to remove the toolbar or prevent this to happen (my preferable solution).

2 Comments

Perhaps the internal black magic from GUIDE is finally breaking?
The solution (for the removal) is probably to put something in the OpeningFcn, but that is a blind guess (I wasn't aware of R2023b until this morning).
Yes, so I have this little function that I put in OpeningFcn that does the job.
function RemoveMatlabToolbar(fig)
% RemoveMatlabToolbar(fig)
% Since R2023b MATLAB GUI add a separate toolbar in the figure
% If you don't want it, call this function in your OpeningFcn
try %#ok
if ~isMATLABReleaseOlderThan("R2023b")
h = findall(fig,'Type','uitoolbar');
%if numel(h) >= 2
Tag = get(h,'Tag');
b = strcmp(Tag,'FigureToolBar'); % This seems to be the default Tag of MATLAB toolbar
delete(h(b));
%end
end
end
end % RemoveMatlabToolbar
But I have quite a umber of GUI figures i many projects. I would like to have the solution to turn off those damn unsollicited toolbars by default.
Oh well, not sure why TMW does this kind of things...

Sign in to comment.

 Accepted Answer

Adam Danz
Adam Danz on 15 Sep 2023
Edited: Adam Danz on 15 Sep 2023
To try to reproduce this behavior, I created a bare-bones gui in R16b and opened it in R23b but the GUI figure does not show any figure toolbar. Please consider contacting tech support and provide them with the GUI files. Or, if you attach them here, I'd be happy to take a look.
In the meantime, does this remove the unwelcomed toolbar?
fig.ToolBar = 'none';
Update @Bruno Luong thanks for digging in. This is due to a change in addToolbarExplorationButtons.
I will send your feedback to the appropriate channels.

7 Comments

@Adam Danz Let me investigate more. The GUI file is too complicated to be shared.
All I know is this works since 2017 up to R2023a.
OK I think I make one step in understanding. The issue is that I have in my startup.m this code
if ~verLessThan('matlab','9.5')
set(groot,'defaultFigureCreateFcn',@(fig,dummy)addToolbarExplorationButtons(fig));
if verLessThan('MATLAB','9.7')
set(groot,'defaultAxesCreateFcn',@(ax,dummy)set(ax.Toolbar,'Visible','off'));
else
set(groot,'defaultAxesCreateFcn', @(ax,varargin) TriggerAxeToolbarRemovalTimer([], ax));
end
end
The culprit is
set(groot,'defaultFigureCreateFcn',@(fig,dummy)addToolbarExplorationButtons(fig));
What is not clear to me is why this line doesn't do anything up to R2023a on GUI figure (but effective in regular figure), and now suddenly it creates the toolbar.
That was helpful, @Bruno Luong. I've updated my answer.
I put here a simple GUI files and my startup.m for investigation
Thanks, this reproduces the behavior you described.
fig = testuitoolbar_R2023B;
addToolbarExplorationButtons(fig) % adds ToolBar in 23b but not prior
@Bruno Luong, could we have more information about your intentions and expectations for this line? Feel free to respond here or contact me directly using the contact button in my profile.
set(groot,'defaultFigureCreateFcn',@(fig,dummy)addToolbarExplorationButtons(fig));
The reason is I don't like the default behavioir of interactive axes toolbar (those icon which appears and disappears on the right sides) so I disable them and restore the figure toolbar everytime I open a new figure, I put this line in my startup file, see this discussion (my post on 16 Sep 2019)
My workaround of the issue in R2023b is that is I try to detect if the figure is assotiated with GUI or not by this code that in principle add the figure toolbar on the standard figure and not GUI figure (it works OK but not very robust):
function AddExporerButtonToFig(fig)
try %#ok
if ~(matlab.ui.internal.isUIFigure(fig)) && ...
~strcmp(fig.HandleVisibility,'callback') && ~isempty(fig.Number)% NOT a GUI, or check like this % isprop(fig,'AutoListeners__')
addToolbarExplorationButtons(fig);
end
end
end

Sign in to comment.

More Answers (0)

Categories

Products

Release

R2023b

Asked:

on 15 Sep 2023

Edited:

on 21 Sep 2023

Community Treasure Hunt

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

Start Hunting!