Callback issue with uiMenu

2 次查看(过去 30 天)
Hanif
Hanif 2013-5-21
Having some issues with callback using uimenu, when a certain option is selected I want it to change the color map of the whole figure. Here is my code.
Function Startup
fig = figure('Toolbar','none','MenuBar','none')
Main = uimenu(fig,'Label','File');
ImageSettings = uimenu(File,'Label','Jet',...
'Callback', 'CM1');
end
function CM1
%colormap(jet)
disp('Jet')
end
The error that occurs is
Too many input arguments.
Error while evaluating uimenu Callback
Also I have tried to change my callback from: 'Callback', 'CM1'); to
'Callback', @CM1);
That did not seem to work either.

采纳的回答

Jan
Jan 2013-5-22
编辑:Jan 2013-5-22
The function CM1 requires 2 input arguments as all callbacks:
function CM1(ObjectHandle, EventData)
You do not have to use the values, but they must exist.
Another idea would be an anomyous function to crop the inputs:
'Callback', @(x,y) CM1
But this looks more confusing, in my opinion.
  1 个评论
Hanif
Hanif 2013-5-28
I get a really weird error when I do that saying:
Maximum recursion limit of 500 reached. Use set(0,'RecursionLimit',N) to change the limit. Be aware that exceeding your available stack space can crash MATLAB and/or your computer.
Error in CreatingMenus>display
Error while evaluating uimenu Callback

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Red 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by