More on the menu fontsize

7 views (last 30 days)
Earlier today I asked a question about increasing the font size of the menu entries without affecting the font size of subsequent plots. Sean graciously answered with the following script:
while ii==1
oldSPPI = get(0,'screenpixelsperinch'); %store old one
kk = menu('choose','me','no me!','go home it''s Friday!');
set(0,'screenpixelsperinch',oldSPPI); %restore
title('Test Plot')
if kk==1
This script removes the problem I had with error messages. But, after it makes the plot using the original smaller font size, it immediately converts the plot back to the larger font size as soon as it returns to the top of the while loop and executes the set statement. So, while the script is idling waiting for a mouse click, the graph has the undesirable large font size. Only if you mouse click on the first choice, "me", and generate kk=1 do you leave the plot in the desired original font size because the while loop does not go back to the first set statement.
Apparently, it is not possible to increase the font size for the menu and leave the plots in their original font size. Is this true?

Accepted Answer

Sean de Wolski
Sean de Wolski on 27 Feb 2012
You misinterpretted by intent. It IS possible to do this, just not with the stock menu() function. You'll have to write your own menu() function (basically a modal figure with a few uicontrols that returns a number. Since you'll be constructing the uicontrols yourself you can give them a nice large fontsize. It should be pretty straightfoward.
Here is something I threw together that should do what you want. It's a bit sloppy on the positioning but could be easily modified to be made pretty:
function selection = mymenu(question,varargin)
%Simple my menu
% -selection = mymenu('Choose one please:','monday','tuesday','wednesday')
% -question: string with question
% -options: n strings of options
% -selection: index of selected button
%Error checking:
assert(nargin >=2 ,'At least two inputs expected');
assert(ischar(question),'question should be a string');
assert(all(cellfun(@ischar,varargin)), 'options should be strings')
%Build figure:
n = length(varargin); %number of options
hF = figure('windowstyle','modal','units','pix','position',[300 300 200 (n+1)*80]);
uicontrol('style','text','position',[10 (n+1)*70,100,20],'string',question);
for ii = n:-1:1
H(ii) = uicontrol('style','push','units','pix','position',[10 (ii-1)*80 150 60],...
%Select and close:
function select(src,~)
idx = 1:n;
selection = idx(ismember(H,src));
Save this is in mymenu.m
  1 Comment
David Koenig
David Koenig on 27 Feb 2012
Thanks, Sean, for your extra trouble to respond to this.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!