I'm building a GUI in MATLAB and currently adding custom menus using uimenu
. I'm trying to add different accelerators to different menu actions.
I've found that passing char(10)
(newline) as the accelerator character in uimenu
(see below) matlab adds Ctrl+ Enter
as that menu's accelerator label. The problem is that it will not run the callback when I hit Ctrl+ Enter
.
Any ideas why this doesn't work? Am I missing something? Is the Ctrl+ Enter
for "run current section" cancelling my call? In that case, can I override it?
Example
A quick demonstrative example of how MATLAB will not accept Ctrl+ Enter
function test
close all
f=figure;
m=uimenu(f,'Label','test');
uimenu(m,'Label','a','callback',@hittest,'Accelerator','r');
uimenu(m,'Label','b','callback',@hittest,'Accelerator',char(10));
function hittest(h,~)
disp(h.Label)
end
end