Borrar filtros
Borrar filtros

check if mouse is on a button

3 visualizaciones (últimos 30 días)
wetlab Technion
wetlab Technion el 30 de Mayo de 2021
Respondida: Jan el 30 de Mayo de 2021
I have an app in MATLAB's app designer and I want the mouse shape to change the pointer (using "setfigptr") depending on whether or not the mouse is hovering on a button. so far I used the WindowButtonMotionFcn, running in a loop over all the buttons and comparing the pointer location to each button. however, now that I have more than 30 buttons I am suspecting that this is slowing down the app a bit because the function is called whenever the mouse is moved. is there a different way to do this?
many thanks
nathan

Respuestas (1)

Jan
Jan el 30 de Mayo de 2021
If you post your code, the readers might see a point, which can be improved.
A solution might be to create a 2D matrix with same number of elements as the figure has pixels. Let the values be 0 outside the pixels and n for the n.th button. Then use the CurrentPoint in units pixels as index of this matrix. So you need 1 test to check all buttons.

Categorías

Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by