colored status indicator in GUI

2 views (last 30 days)
veronica bogu
veronica bogu on 21 Jun 2015
Commented: veronica bogu on 22 Jun 2015
i'm trying to crate a text box that changes color if Mat lab is connected to arduino controller.
using the following code, it does not work:
function text3_CreateFcn(hObject, eventdata, handles)
% hObject handle to text3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
%ADD THE CHECK FUNCTION HERE (as an if function)
global a;
if a.roundTrip(42)==1
set(hObject,'text3_CreateFcn','red');
else
end
% UIWAIT makes guiarduino wait for user response (see UIRESUME)
% uiwait(handles.figure1);
guidata(hObject, handles);
i could not find a simple solution to this problem. thanks!
veronica

Accepted Answer

Jan
Jan on 21 Jun 2015
When should the color change to red? The CreateFcn runs during the creation of the figure.
This cannot work:
set(hObject, 'text3_CreateFcn', 'red');
Look at the documentation of set again. This commands sets a pre-defined property of the text object, but "text3_CreateFcn" is no property. Perhaps you want:
set(hObject, 'BAckgroundColor', 'red');
But I'm in doubt that the CreateFcn is the correct place to do this.
  1 Comment
veronica bogu
veronica bogu on 22 Jun 2015
the color should change if adruino is working
a.roundTrip(42)==1
how can i change background color as part of if /else .?
thank you.

Sign in to comment.

More Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!