필터 지우기
필터 지우기

How to set GUI edit box background color to default gray?

조회 수: 16 (최근 30일)
Peng Zhao
Peng Zhao 2019년 7월 2일
답변: Peng Zhao 2019년 7월 16일
I have an edit box which I want to set to default gray ([0.941 0.941 0.941]) when it's not used.
% --- Executes during object creation, after setting all properties.
function OtherPI_CreateFcn(hObject, eventdata, handles)
% hObject handle to OtherPI (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
% if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
% set(hObject,'BackgroundColor','white');
% end
set(hObject,'BackgroundColor',[0.941 0.941 0.941])
I tried it in the create function, and the GUI opening function and it did not work.
but it works when I use other background colors.
So it might be the RGB Triplet is wrong? what should I use for the default gray in GUI?
  댓글 수: 2
Peng Zhao
Peng Zhao 2019년 7월 2일
편집: Peng Zhao 2019년 7월 2일
I've also tried setting the background color in the Property Inspector:
And it did not work.
Geoff Hayes
Geoff Hayes 2019년 7월 2일
Peng - can you clarify what you mean by it did not work. Are you seeing a different grey? What background colours does it work for?

댓글을 달려면 로그인하십시오.

채택된 답변

Peng Zhao
Peng Zhao 2019년 7월 16일
If use [0.94 0.94 0.94], the color seems like the default gray.
[0.94 0.94 0.94]

추가 답변 (1개)

Kavya Vuriti
Kavya Vuriti 2019년 7월 16일
Hi,
I think RGB triplet for default gray color is [0.5 0.5 0.5]. Hope it solves your problem.

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

제품


릴리스

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by