print figure shows hidden objects

9 views (last 30 days)
I have a gui that I created without using guide. There are various configurations, and I switch between them by hiding gui elements. This works great up until the user tries to do a screen print, where this piece of code from "prepare.m" is invoked by the "print" function:
%Need to see everything when printing hiddenH = get( 0, 'showhiddenhandles' ); set( 0, 'showhiddenhandles', 'on' )
Not clear why we need to see everything when printing, makes no sense to me. If I want to show the hidden handles, I'd make them visible. Any suggestions?

Accepted Answer

Eric Keller
Eric Keller on 6 May 2011

More Answers (3)

Jan
Jan on 4 Apr 2011
"set(0, 'showhiddenhandles', 'on')" does not make anything visible. It allows to include the handles a.g. when getting the children of an HG-object. See also:
docsearch ShowHiddenHandles
docsearch HandleVisibility
What problems do occur when printing?

Eric Keller
Eric Keller on 5 May 2011
that just means I didn't find the right line of code. This program shows the behavior I have seeing. When you open the jpeg, you get a surprise.
function bugshowD
h_main = figure('name', 'bugshowD', ...
'Visible', 'on', ...
'OuterPosition', [200 200 360 360]);
hprintbutton = uicontrol(h_main, ...
'Style', 'pushbutton', ...
'Position', [10 10 70 70], ...
'String', 'Print',...
'Callback', @printsave);
hpanel = uipanel('Parent', h_main, ...
'Position',[ 110 110 240 240], ...
'Title', 'Panel',...
'visible','off');
hhiddenbutton = uicontrol(hpanel, ...
'Style', 'pushbutton', ...
'Position', [5 5 70 70], ...
'String', 'neverseen',...
'Callback', @nothing,...
'visible','on');
function printsave(windowname,~)
[ffile, fpath, findex] = uiputfile( ...
{'*.jpg', 'jpeg file (*.jpg)';
'*.eps', 'encapsulated postscript file (*.eps)'},...
'save screen capture', 'screenprint');
print(['-f' num2str(h_main)], fullfile(fpath, ffile), '-djpeg80', '-r300')
end
end

Eric Keller
Eric Keller on 5 May 2011
I'd just like to add that when I wrote this little program, and omitted the uipanel, that it didn't show the hidden button. This makes me think that it's just a bug with hidden uipanels. This behavior also shows up if you use printdlg

Categories

Find more on Entering Commands in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!