MATLAB Answers

help fast pls / buttondwnfcn

1 view (last 30 days)
Max Müller
Max Müller on 28 Sep 2014
Answered: Geoff Hayes on 28 Sep 2014
hey Guys, I have create an text object using uicontrol and set the 'buttondownfcn' to be @Click. Now the problem is: it works only on a right click. If i click with the left mouse button on it, it does nothing.....I dont get why. In Prevouis programs it work perfectly.
ChosenShot = [num2str(InputData.shot),' ','Closest',' ','Amp.'];
Tag = [num2str(InputData.shot),'_ClosestAmp'];
uicontrol('style','text',buttondownfcn',@Click)
Counter = Counter +1;

  0 Comments

Sign in to comment.

Accepted Answer

Geoff Hayes
Geoff Hayes on 28 Sep 2014
If the uicontrol's "Enable" property is set to "on", the ButtonDownFcn callback executes when you click the right or left mouse button in a 5-pixel border around the uicontrol or when you click the right mouse button on the control itself.
I verified the above with your example (R2014a). If I left-clicked within the 5-pixel border around the text box, then the callback fired. If I right-clicked within the 5-pixel border around the text box or within the text box, then the callback fired.
The other post also goes on to say that
If the uicontrol's "Enable" property is set to "inactive" or "off", the ButtonDownFcn executes when you click the right or left mouse button in the 5-pixel border or on the control itself.
I took your code, and modified it as follows
h=uicontrol('style','text','buttondownfcn',@Click) ;
set(h,'Enable','off');
Once I ran the above, I could left-click or right-click within the text box (uicontrol) and observe that the callback fired.

  0 Comments

Sign in to comment.

More Answers (0)

Sign in to answer this question.