help fast pls / buttondwnfcn

1 次查看(过去 30 天)
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;

采纳的回答

Geoff Hayes
Geoff Hayes 2014-9-28
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 个)

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by