Edit model context menu
2 views (last 30 days)
Show older comments
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!
0 Comments
Answers (1)
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
0 Comments
See Also
Categories
Find more on Simulink Environment Customization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!