Display different Color in a popup menu using GUIDE
3 views (last 30 days)
Show older comments
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 Comments
Walter Roberson
on 26 Apr 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.
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!