How can I execute a double-click callback without executing the single-click callback in my MATLAB GUI?
48 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
MathWorks Support Team
le 5 Déc 2011
Réponse apportée : CAM
le 26 Mar 2015
In order to set a double-click callback for my figure, I must set the SelectionType property to "open." However, when I double-click on my figure, MATLAB cycles the SelectionType through "normal" while I am clicking. This triggers my single-click callback. Thus both callbacks are executed instead of only my double-click callback.
Réponse acceptée
MathWorks Support Team
le 5 Déc 2011
You can use the following sample code to cause your application to execute only the double-click callback:
Associate this function with 'WindowButtonDownFcn' callback of the figure window.
function clickcallback(obj,evt)
persistent chk
if isempty(chk)
chk = 1;
pause(0.5); %Add a delay to distinguish single click from a double click
if chk == 1
fprintf(1,'\nI am doing a single-click.\n\n');
chk = [];
end
else
chk = [];
fprintf(1,'\nI am doing a double-click.\n\n');
end
0 commentaires
Plus de réponses (1)
CAM
le 26 Mar 2015
I am disappointed that GUI's do not (apparently) support the double-click option in SelectionType. Why is there no disclaimer in the help files about this?
When will this bug be fixed?
0 commentaires
Voir également
Catégories
En savoir plus sur Debugging and Analysis dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!