Skip to content

Commit

Permalink
esfit: support log box context menu <=R2016b
Browse files Browse the repository at this point in the history
  • Loading branch information
stestoll committed Aug 28, 2022
1 parent 124cd3a commit 9b9d7bc
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions easyspin/esfit.m
Original file line number Diff line number Diff line change
Expand Up @@ -2182,26 +2182,24 @@ function setupGUI(data)
'FontWeight','bold','String','Log',...
'Tooltip','Fitting information and error log',...
'HorizontalAl','left');
try
copymenu = uicontextmenu(hFig);
uimenu(copymenu,'Text','Copy to clipboard','Callback',@copyLog);
uicontrol('Parent',hFig,'Style','listbox','Tag','LogBox',...
'Position',[Logx0 Logy0 Logw Logh],...
'String',{''},'Tooltip','',...
'HorizontalAlignment','left',...
'Min',0,'Max',2,...
'Value',[],'Enable','inactive',...
'ContextMenu',copymenu,...
'BackgroundColor',[1 1 1])
catch
uicontrol('Parent',hFig,'Style','listbox','Tag','LogBox',...
hLogBox = uicontrol('Parent',hFig,'Style','listbox','Tag','LogBox',...
'Position',[Logx0 Logy0 Logw Logh],...
'String',{''},'Tooltip','',...
'HorizontalAlignment','left',...
'Min',0,'Max',2,...
'Value',[],'Enable','inactive',...
'BackgroundColor',[1 1 1])
warning('Could not create context menu for copying log to clipboard.')
'BackgroundColor',[1 1 1]);

copymenu = uicontextmenu(hFig);

if ~verLessThan('Matlab','9.2') % >R2016b
% In R2016b, uimenu does not support Text, and uicontrol does
% not support ContextMenu.
uimenu(copymenu,'Text','Copy to clipboard','Callback',@copyLog);
hLogBox.ContextMenu = copymenu;
else
uimenu(copymenu,'Label','Copy to clipboard','Callback',@copyLog);
hLogBox.UIContextMenu = copymenu;
end

drawnow
Expand Down

0 comments on commit 9b9d7bc

Please sign in to comment.