在GUI中选择UIControl

时间:2015-09-14 15:10:53

标签: matlab matlab-guide

如何找出用户当前选择的给定MATLAB GUI中的哪个控件?

例如,我想找出GUI中当前关注的哪个编辑框,因为我想利用数字WindowScrollWheelFcn来允许在选择相关输入时向上/向下滚动来增加/减少数值。

1 个答案:

答案 0 :(得分:2)

Let f be a handle to the GUI figure. Then

h = get(f, 'CurrentObject')

returns a handle h to that figure's current object, which is the one most recently selected in that figure (see the documentation of figure properties for more information).

(Note that gco returns the current object in the current figure. This is not what you want, because the user may have clicked an object in another figure).