1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| function Essai
% Variables
OuiNon = true;
Jaune = [1 1 0.8];
Violet = [0.7 0.7 1];
% Ouverture de la figure
hFigure = figure(...
'MenuBar', 'none', ...
'Units', 'Pixels', ...
'Position', [0 0 300 100], ...
'Visible', 'off');
movegui(hFigure, 'center');
% Construction des objets
hEdit(1) = uicontrol(...
'Style','edit', ...
'Units','normalized',...
'Position', [0.1 0.3 0.2 0.2], ...
'Enable', 'inactive', ...
'ButtonDownFcn', @Select, ...
'BackgroundColor', Jaune, ...
'String', 'Cliquez ici');
hEdit(2) = uicontrol(...
'Style','edit', ...
'Units','normalized',...
'Position', [0.7 0.3 0.2 0.2], ...
'Enable', 'inactive', ...
'ButtonDownFcn', @Select, ...
'BackgroundColor', Violet, ...
'String', 'ou ici');
set(hFigure, 'Visible', 'on');
% Fonction Callback
function Select(source, eventdata)
set(hEdit(OuiNon + 1), 'BackgroundColor', Jaune);
OuiNon = not(OuiNon);
set(hEdit(OuiNon + 1), 'BackgroundColor', Violet);
end
end |
Partager