Edit model context menu

2 views (last 30 days)
Marius Grigore
Marius Grigore on 14 May 2018
Answered: Monika Jaskolka on 15 May 2018
I added a new option in model context menu with sl_customization function which calls a function.
function sl_customization(cm)
cm.addCustomMenuFcn('Simulink:PreContextMenu', @getMyMenuItems);
end
function schemaFcns = getMyMenuItems(callbackInfo)
schemaFcns = {@getLC};
end
function schema = getLC(callbackInfo)
schema = sl_action_schema;
schema.label = 'MyOption';
schema.userdata = 'myUserData';
schema.callback = @myOption;
end
function myOption(callbackInfo)
% here I want to identify if my option was called after a right-click
% on the model white space or if was called after right-clicked on a
% block (I want the handle or path to this block)
end
As I commented in the last function I want to find from where was called. I tried to find something in callbackInfo but I couldn't find what I wanted. Should I do it differently? If you need any details please let me know.
Thank you!

Answers (1)

Monika Jaskolka
Monika Jaskolka on 15 May 2018
function myOption(callbackInfo)
selection = find_system(gcs, 'Type', 'block', 'Selected', 'on');
if isempty(selection)
disp('Nothing selected');
else
disp('Block(s) selected');
end
end

Categories

Find more on Simulink Environment Customization in Help Center and File Exchange

Products


Release

R2014b

Community Treasure Hunt

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

Start Hunting!