Edit model context menu

1 visualización (últimos 30 días)
Marius Grigore
Marius Grigore el 14 de Mayo de 2018
Respondida: Monika Jaskolka el 15 de Mayo de 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!

Respuestas (1)

Monika Jaskolka
Monika Jaskolka el 15 de Mayo de 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

Categorías

Más información sobre Simulink Environment Customization en Help Center y File Exchange.

Productos


Versión

R2014b

Community Treasure Hunt

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

Start Hunting!

Translated by