Edit model context menu

1 Ansicht (letzte 30 Tage)
Marius Grigore
Marius Grigore am 14 Mai 2018
Beantwortet: Monika Jaskolka am 15 Mai 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!

Antworten (1)

Monika Jaskolka
Monika Jaskolka am 15 Mai 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

Kategorien

Mehr zu Simulink Environment Customization finden Sie in Help Center und File Exchange

Produkte


Version

R2014b

Community Treasure Hunt

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

Start Hunting!

Translated by