Get Simulink mouse click position

6 ビュー (過去 30 日間)
Guillaume
Guillaume 2023 年 9 月 14 日
コメント済み: Guillaume 2023 年 10 月 3 日
Hello,
I add some tools in Simulink context menu in order to be more efficient in common tasks (block creation, parametrization, positionning...).
I would like to be able to create blocks at the exact location of the user right click. But I don't know how to get the last click position in a Simulink model (in Simulink coordinate system).
I found this post but the mentionned property 'ModelBrowserWidth' does not exist anymore. I am quite stuck with my issue.
I tried a few things with :
get_param(gcs,'Location')
get(0,'PointerLocation');
But I did not manage to do what I want : get the Simulink position of the last click in any situation (several screens, model browser open/closed...).
Any help woulp be very appreciated.
Thank you.

回答 (1 件)

Gagan Agarwal
Gagan Agarwal 2023 年 10 月 3 日
Hi Guillaume,
I understand that you are trying to capture the position of a right-click in the model workspace of Simulink.
Currently, Simulink does not provide a built-in callback specifically for keyboard or mouse events. However, Simulink does offer callbacks for various modeling actions such as model, block, and port-related events.
As a work around you can create a dashboard and implement a MATLAB script callback using the 'Callback Button'. The callback can be configured to run based on a click or press of the button.
Please refer to the following documentation link for better understanding of the modelling callbacks.
I hope this helps!
  1 件のコメント
Guillaume
Guillaume 2023 年 10 月 3 日
Hi Gagan,
Thank you for your input.
My purpose is to create blocks programmaticaly in any block diagram regardless of their content. I cannot rely on a specific block or callback in the models.
I have a sl_customization file that registers a lot of utilitary functions added in the context menu. Some of my functions would like to be able to create blocks at the exact location of the right click.
Currently I simply determine an empty location in the system to put my blocks, it would be more convenient to put it directly at the click position but this is not mandatory.
Thak you again.

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

カテゴリ

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

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by