私のGUIには2つの編集ボックス(uicontrol)があり、左クリックして背景色を変更したいと思います。左マウスクリックの場合、ButtonDownFcnはuicontrol Enableプロパティが 'inactive'または 'off'に設定されている場合にのみ機能します。uicontrolのButtonDownFcn
タブキーを押すと、自分の背景色を白に再初期化し、次の編集ボックスの背景色を変更したいと思います。問題は、タブキーを押すと、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
を使用して発見され、それは完璧に動作、ありがとうございます。ちょうど1つの詳細:gainFocus関数(hFig)の最初の引数は使用されないため、削除することができます。 – oro777