Display different Color in a popup menu using GUIDE
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi there,
I’m trying to create a popup menu for Color Selection. I managed to display the different Colors in the popup menu (see first picture) ...

but since one is selected it doesn’t display the Color anymore. Instead it shows the HTML Code that I am using to display the Color (second picture)

Can someone please help displaying the selected Color? Tanks a lot!
My Code is the following:
%HTML text to display Colors
colergen = @(color,text) ['<html><table border=0 width=50 bgcolor=',color,'><TR><TD>',text,'</TD></TR> </table></html>'];
set(handles.uitable1, 'columnname', {'Region', 'visible', 'Color'});
set(handles.uitable1, 'columneditable', [true,true,true])
col_fmt = get(handles.uitable1, 'ColumnFormat');
col_fmt{3} = {colergen('#353477', ' '), colergen('#EBF4FC', ' '), colergen('#FFF7E7', ' ')}
set(handles.uitable1, 'ColumnFormat', col_fmt);
set(handles.uitable1, 'columneditable', [true,true,true])
Names = {'Region 01', true, ''; 'Region 02', true, ''};
set(handles.uitable1, 'data', Names);
3 commentaires
Walter Roberson
le 26 Avr 2018
For columns defined to be pop-up menus, the value at each cell location in that row is the index of the selected entry.
data = get(handles.uitable1, 'data');
mask = cellfun(@isempty, data(:,3));
data(mask,3) = {0};
selections = cell2mat(data(:,3));
I do not know at the moment whether it is possible for there to be empty selections so I decided it would be safer to put that code in.
Réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!