To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016
I can create a uicontrol('Style','popup') with a 'backgroundcolor'. This works and the color is the one I chose. However, as soon as I select any value, the background color goes to a grayish, with the text in the foreground color I have set. The selected pop-up entry does not use the background color.
Is there a way to control the background color of a selected pop-up entry?
(I am trying to color-code my uicontrols according to the major class of functionality they have within the terms of my program. Although I could in theory do so just by adjusting their text foreground colors, the area of the text compared to the area of the control is relatively small and the color coding of the text is not nearly as distinguishable as color coding the background.)
The selected pop-up gets the different color as long as the UICONTROL has the focus. Although Matlab's documentation claims that "figure(gcf)" gives the focus to the figure, this does not work from at least Matlab 5.3 to 2009a. Therefore I usually insert a call to a function named "FocusToFig" in the UICONTROL's callback function:
function FocusToFig(ObjH, EventData) %#ok<INUSD> % Move focus to figure % FocusToFig(ObjH, [DummyEventData]) % INPUT: % ObjH: Handle of a graphics object. It is tried to move the focus to the % parent figure and making it the CurrentFigure of the root object. % DummyEventData: The 2nd input is optional and ignored. % % Tested: Matlab 6.5, 7.7, 7.8, WinXP % Author: Jan Simon, Heidelberg, (C) 2009-2011
if any(ishandle(ObjH)) % Catch no handle and empty ObjH FigH = ancestor(ObjH, 'figure'); if strcmpi(get(ObjH, 'Type'), 'uicontrol') set(ObjH, 'enable', 'off'); drawnow; set(ObjH, 'enable', 'on'); end
% Methods according to the documentation (does not move the focus for % keyboard events under Matlab 5.3, 6.5, 2008b, 2009a): figure(FigH); set(0, 'CurrentFigure', FigH); end
This moves the keyboard focus also to the figure, such that the KeyPressFcn is called again.