Changing color of Button
Show older comments
With some help i've created a variable amount of buttons in my gui:
for n=1:s
handles.b{n}=uicontrol('Style','PushButton','Units','pixels', 'Position',[125-breiteQuadrat/2-5+breiteQuadrat*n 45 10 10],'Visible','on');
end
Now i want to colour the button when it is selected and when you click twice it has the start-colour. here i call the callback function:
for n=1:s
set(handles.b{n},'Callback',@(obj,event)varBButton_Callback(n,hObject,eventdata,handles));
end
for the callback i implemented a new function:
function varBButton_Callback(n,hObject, eventdata, handles)
if get(handles.b{n},'Value')==get(handles.b{n},'Max')
set(handles.b{n},'BackgroundColor',[1 0 0],'Value','Min');
set(handles.tauschButton,'enable','on');
set(handles.deaktivierenButton,'enable','on');
else
set(handles.b{n},'BackgroundColor',[1 1 1],'Value','Max');
end
guidata(hObject, handles);
the change of the value doesn't work but i can't find my mistake.
and after that i want that it is possible to remove or change the position of the selected button. maybe someone has an idea how to realize that problem Thank you
Accepted Answer
More Answers (0)
Categories
Find more on App Building in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!