Edit model context menu
조회 수: 4 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Monika Jaskolka
2018년 5월 15일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Simulink Environment Customization에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!