Accurately Insert a Block in Simulink Model based on Mouse Position.
Afficher commentaires plus anciens
Hi, I want to insert a Block into a Simullink Model from Right Click Menu. The block should be inserted into the exact 'position' of the mouse right click. To calculate the 'position' i use
locationBase = get_param(modelName,'Location');%To account for floating windows etc
scrollOffset = get_param(modelName,'ScrollbarOffset');%To account for ScrollBar Position
I calculate the 'position' by
p_X = mousePositionX - locationBase(1) + scrollOffset(1);
p_Y = screenSizeY - mousePositionY - locationBase(2) + scrollOffset(2) ;
I add the block dimensions to find the 'position' to insert the blocks like this.
location = [p_X p_Y p_X+BlockWidth+BlockHeight];
This works well if the Model Browser is not open. If Model Browser is open, It adds additional offset to the position and the Blocks are inserted at the wrong place. How can I include offsets created by the Model Browser?
1 commentaire
Abhishek Vaidya
le 1 Mar 2020
How are you finding out the mousePositionX and mousePositionY
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Programmatic Model Editing dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!