How to add a callback function to mouse-click event inside a Simulink model but outside any block or line?

2 ビュー (過去 30 日間)
HI, I am creating a plugin tool for Simulink to help users during model development. When creating their Simulink model in Simulink workspace/window, whenever the user clicks somewhere inside the simulink workspace (but outside any block or line), I need to execute a callback function. How do I do this?
PS. I was able to add callback functions to blocks (by temporarily overriding their 'openfcn' function). I need something simillar so that I can execute a callback function when the user clicks outside of any block, but still inside the simulink workspace.
I NEED TO CALL THE CALLBACK FUNCTION WHEN CREATING THE SIMULINK MODEL, NOT WHILE RUNNING A SIMULATION.
Thank you!
  3 件のコメント
Bhisma Adhikari
Bhisma Adhikari 2020 年 8 月 18 日
Hi Stozaki,
Thank you very much for your solution. For my intended use, this solution is not "best" though, because adding a contenxt menu option would make that added option always available (which is not something I want). I could circumvent this by dynamically editing and reloading sl_customization.m file during runtime to add/remove that option, but as I see, executing sl_refresh_customizations takes several seconds (something I cannot afford for my application).
If you could provide me a way to "intercept" mouse click events inside the simulink workspace (not inside a figure window), that would be very helpful.
stozaki
stozaki 2020 年 8 月 19 日
Hello Bhisma,
If you use a left click on the Simulink canvas, the Quick Block Insert function will work.
The following is a workaround, but using the annotation's click function seems to work. Can you apply this?
I attached a simple model.
Regards,
stozaki

サインインしてコメントする。

採用された回答

Bhisma Adhikari
Bhisma Adhikari 2020 年 8 月 19 日
Hi Stozaki,
Thank you very much for your solution! I appreciate your efforts to create testmodel.slx.
Actually, I was looking for a way just to capture the mouse click event on the Simulink canvas (blank area), not in a particular block/line/annotation, so that I can trigger some function. Perhaps, Simulink does not allow this (I don't know).
Your solution still requires creating an annotation element, which is not the best solution to my use-case, but is something I can settle with.
Thank you very much!

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSimulink Environment Customization についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by