【发布时间】:2017-11-17 12:20:39
【问题描述】:
我的 GUI 有两个编辑框 (uicontrol),我想通过左键单击来更改它们的背景颜色。对于鼠标左键单击,ButtonDownFcn 仅在 uicontrol Enable 属性设置为“inactive”或“off”时才有效,因此我切换该属性以使其工作。
通过按 Tab 键,我希望我的编辑框将其背景颜色重新初始化为白色,并更改下一个编辑框的背景颜色。问题是按下tab键,焦点不会改变,因为uicontrol Enable属性是'off'或'inactive'。 有解决办法吗?
到目前为止,这是我的代码。 (edit1和edit2代码相同)
function edit1_ButtonDownFcn(hObject, eventdata, handles)
set(hObject, 'Enable', 'on', 'BackgroundColor', [0.5,1,0.7]) % change enable and background color properties
uicontrol(hObject) % focus on the current object
function edit1_Callback(hObject, eventdata, handles)
set(hObject, 'Enable', 'inactive', 'BackgroundColor', [1 1 1]) % reinitialize the edit box
【问题讨论】:
标签: matlab user-interface callback uicontrol