我的GUI有两个编辑框(uicontrol),我想通过左键单击它来更改它们的背景色。对于鼠标左键单击,仅当uicontrol启用属性设置为'inactive‘或'off’时,ButtonDownFcn才起作用,因此我切换该属性使其起作用。
通过按Tab键,我希望我的编辑框将它们的背景颜色重新初始化为白色,并更改下一个编辑框的背景颜色。问题是按Tab键,焦点不会改变,因为uicontrol启用属性是'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 boxhttps://stackoverflow.com/questions/44560163
复制相似问题