different reactions to right/left click
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Stepan Vecera
el 11 de Mayo de 2021
Comentada: Stepan Vecera
el 12 de Mayo de 2021
hi, i have array of buttons and i would like to have different reaction to right/left click. can i do it in one function? i have tried using selectiontype, but i cant figure it out myself
2 comentarios
Jan
el 11 de Mayo de 2021
Editada: Jan
el 11 de Mayo de 2021
Are talking about figures or uifiguires? Did you create the GUI by code, GUIDE or AppDesigner? Please post the code you have tried and explain, which problems it has. Then it is much easier to suggest a solution. The less the readers have to guess, the more likely suggestions match your problem.
The EventData should allow you to distinguish the mouse keys.
Stepan Vecera
el 11 de Mayo de 2021
Editada: Stepan Vecera
el 12 de Mayo de 2021
Respuesta aceptada
Jan
el 12 de Mayo de 2021
Editada: Jan
el 12 de Mayo de 2021
Comparing char vectors by == fails, if the number of characters is not equal.
'123' == 'abc' % Working
'1234' == '0' % Working, because 1 variable is a scalar
'12' == 'abc' % error
Use strcmp instead.
The SelectionType is a property of the figure:
function buttonPushed(hObj, ~)
hFig = ancestor(hObj, 'figure');
Selection = get(hFig, 'SelectionType')
if strcmp(Selection, 'alt')
...
end
Más respuestas (0)
Ver también
Categorías
Más información sobre Maintain or Transition figure-Based Apps en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!