print figure shows hidden objects

2 visualizzazioni (ultimi 30 giorni)
Eric Keller
Eric Keller il 4 Apr 2011
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?

Risposta accettata

Eric Keller
Eric Keller il 6 Mag 2011

Più risposte (3)

Jan
Jan il 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 il 5 Mag 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 il 5 Mag 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

Categorie

Scopri di più su Migrate GUIDE Apps in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by