- Undocumented Matlab - https://undocumentedmatlab.com -

Displaying hidden handle properties

Posted By Yair Altman On May 5, 2009 | 14 Comments

Matlab Handle Graphics (HG) is a great way to manipulate GUI objects. HG handles often have some undocumented hidden properties. One pretty well-known example is the JavaFrame property of the figure handle, which enables access to the GUI’s underlying Java peer object. We can use hidden properties just like any other handle property, using the built-in get and set functions.

But how can we know about these properties? Here are two methods to do so. Like the hidden properties, these two methods are themselves undocumented…

1. use the desktop’s hidden HideUndocumented property:

set(0,'HideUndocumented','off');

From now on, when displaying handle properties using get and set you’ll see the hidden properties.

Note that some of the properties might display a warning indication:

>> get(gcf)
	Alphamap = [ (1 by 64) double array]
	BackingStore = on
	CloseRequestFcn = closereq
	Color = [0.8 0.8 0.8]
	Colormap = [ (64 by 3) double array]
	CurrentAxes = []
	CurrentCharacter = 
	CurrentKey = 
	CurrentModifier = [ (1 by 0) cell array]
	CurrentObject = []
	CurrentPoint = [0 0]
	DithermapWarning: figure Dithermap is no longer useful
 with TrueColor displays, and will be removed in a future release.
 = [ (64 by 3) double array]
        ...

2. Access the properties’ definition in the handle’s class definition:

>> ch = classhandle(handle(gcf));
>> props = get(ch,'Properties');
>> propsVisibility = get(props,'Visible')';
>> hiddenProps = props(strcmp(propsVisibility,'off'));
>> sort(get(hiddenProps,'Name'))
ans = 
    'ALimInclude'
    'ActivePositionProperty'
    'ApplicationData'
    'BackingStore'
    'Behavior'
    'CLimInclude'
    'CurrentKey'
    'CurrentModifier'
    'Dithermap'
    'DithermapMode'
    'ExportTemplate'
    'HelpFcn'
    'HelpTopicKey'
    'HelpTopicMap'
    'IncludeRenderer'
    'JavaFrame'
    'OuterPosition'
    'PixelBounds'
    'PrintTemplate'
    'Serializable'
    'ShareColors'
    'UseHG2'
    'WaitStatus'
    'XLimInclude'
    'YLimInclude'
    'ZLimInclude'

Different HG handles have different hidden properties. Not all these properties are useful. For example, I have found the PixelBounds property to be problematic – (it sometimes reports incorrect values!). Other properties (like Dithermap or ShareColors) are deprecated and display a warning wherever they are accessed.

But every so often we find a hidden property that can be of some actual benefit. Let’s take the figure handle’s OuterPosition property for example. It provides the figure’s external position values, including the space used by the window frame, toolbars etc., whereas the regular documented Position property only reports the internal bounds:

>> get(gcf,'pos')
ans =
   232   246   560   420
>> get(gcf,'outer')
ans =
   228   242   568   502

In future posts I will sometimes use such hidden properties. You can find the latest list by looking at this blog’s “Hidden property” [3] category page.

Note: Like the rest of Matlab’s undocumented items, all hidden properties are undocumented, unsupported and may well change in future Matlab releases so use them with care.

Did you find any useful hidden property? If so, then please leave your finding in the comments section below.

Categories: Hidden property, High risk of breaking in future versions


14 Comments (Open | Close)

14 Comments To "Displaying hidden handle properties"

#1 Comment By Steve Eddins On May 6, 2009 @ 4:40 am

Hi Yair. The OuterPosition property of figures is [10], although I see that get(gcf) doesn’t display it by default. I don’t know the reason for the discrepancy.

#2 Comment By Yair Altman On May 6, 2009 @ 10:22 am

Thanks Steve – that’s a nice catch that I probably would never have seen…
Hidden but documented: that’s a new one – I learn something new each day :-)

#3 Comment By Matt Whitaker On May 15, 2009 @ 3:45 pm

One nice little property of axes (using R2009a) is ‘ContentsVisible’. Seems to be a nice way of toggling off the visibility contents of an axes while you update it.


plot(1:5)
t = text('Parent',gca,'String','Some Text');
set(gca,'ContentsVisible','off')
hold on
plot(5:-1:0)
set(t,'Position',[3,3])
set(gca,'ContentsVisible','on')

Sure it can be done numerous other ways but one scenario I have encountered is having a bunch of objects in an axes that have a mixture of visible states. You want to hide the contents while some update goes on. You have to find all the visible children, turn them off, keep that list in memory to only restore the visible stuff. The above seems much cleaner. I have not run into any gotchas yet.

Thanks for the great website. You’ve been a great help over the last couple of years.

Matt

#4 Comment By Jason McMains On May 29, 2009 @ 5:16 am

Yair, I’ve been looking around your getjframe program to get more of these “hidden handle properties.” This adds a lot of great extra functionality! Thanks for that! My question is that for some reason if I set the figure as invisible, all of those hidden callbacks, ie ‘WindowStateChangedCallback’ stop running. Any ideas?

Thanks
Jason

#5 Comment By Yair Altman On May 30, 2009 @ 11:07 am

@Jason – the Java properties & callbacks are only relevant for visible figure frames. After all, how can you minimize/maximize a hidden frame??? Still, you can access these properties if you simply keep the figure visible and just set its position to somewhere off-screen (say, x=y=9999). The figure will remain visible although effectively hidden from view; it will remain displayed in the taskbar for this reason.

#6 Comment By Jason McMains On June 9, 2009 @ 4:09 am

@Yair Unfortunately part of the code I’m working on is to “minimize to the system tray” like I can do in outlook and some other programs, which involves setting the visibility off to remove it from the task bar. I’ve gotten it to work some of the time, but certain sequences of commands still mess it up. The system tray icon is a great extra resource by the way, thanks for that little piece of wisdom:)

#7 Comment By Jason McMains On June 22, 2009 @ 11:26 am

@Yair, I finally think I figured out the problem, but its just a simple logic fix, every time I set the figure back to visible, I get the javaframe, and include that as the callback argument, and remove the old javaframe.

#8 Comment By Cris On September 28, 2009 @ 2:40 am

Hey Yair, nice blog!

The ‘ApplicationData’ property might not be documented, but the GETAPPDATA and SETAPPDATA access functions are. It’s just a better structured implementation of the ‘UserData’ property. I still prefer using ‘UserData’ just because it’s more flexible. You get an error if you try to write anything that is not a stuct into ‘ApplicationData’.

#9 Pingback By Customizing print setup | Undocumented Matlab On November 25, 2009 @ 1:27 pm

[…] the figure-specific print setup is stored in another hidden property, PrintTemplate […]

#10 Pingback By Axes LooseInset property | Undocumented Matlab On March 24, 2010 @ 11:18 am

[…] another undocumented property of Matlab axes, ContentsVisible, was described by Matt Whittaker in a comment on my original article that introduced undocumented properties […]

#11 Pingback By Matlab’s HG2 mechanism | Undocumented Matlab On May 7, 2010 @ 3:53 am

[…] “Handle Graphics 2nd generation”, was already reported in the past as an undocumented hidden figure property (UseHG2). In normal Matlab usage, this boolean property is ‘off’: >> […]

#12 Pingback By FIG files format | Undocumented Matlab On December 22, 2010 @ 1:01 pm

[…] we can see hidden/undocumented properties of the stored objects (for example, the lineseries’ XDataJitter and ObeyXDataMode properties) […]

#13 Pingback By getundoc – get undocumented object properties | Undocumented Matlab On September 21, 2011 @ 12:02 pm

[…] Which is where today’s post can help, by showing you how to list these hidden properties. I wrote about this a couple of years ago, and today’s article will expand on that original post. […]

#14 Comment By Ramiro Massol On June 23, 2014 @ 1:34 pm

hi Yair
Just to let you know new bad news about Matlab. I was testing the pre-release of Matlab 2014b. The “set(0,’HideUndocumented’,’off’);” does not work anymore, which may mean that all the undocumented properties and functions relying on them may not work anymore (for instance, uicomponent does not work).
best


Article printed from Undocumented Matlab: https://undocumentedmatlab.com

URL to article: https://undocumentedmatlab.com/blog/displaying-hidden-handle-properties

URLs in this post:

[1] Image: http://undocumentedmatlab.com/feed/

[2] email feed: http://undocumentedmatlab.com/subscribe_email.html

[3] “Hidden property”: https://undocumentedmatlab.com/blog/category/Hidden-property/

[4] Draggable plot data-tips : https://undocumentedmatlab.com/blog/draggable-plot-data-tips

[5] Figure window customizations : https://undocumentedmatlab.com/blog/figure-window-customizations

[6] Matlab’s HG2 mechanism : https://undocumentedmatlab.com/blog/matlab-hg2

[7] New information on HG2 : https://undocumentedmatlab.com/blog/new-information-on-hg2

[8] Undocumented cursorbar object : https://undocumentedmatlab.com/blog/undocumented-cursorbar-object

[9] Handle Graphics Behavior : https://undocumentedmatlab.com/blog/handle-graphics-behavior

[10] : http://www.mathworks.com/access/helpdesk/help/techdoc/ref/figure_props.html

Copyright © Yair Altman - Undocumented Matlab. All rights reserved.