<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
><channel><title>Undocumented Matlab &#187; UIInspect</title> <atom:link href="http://undocumentedmatlab.com/blog/tag/uiinspect/feed/" rel="self" type="application/rss+xml" /><link>http://undocumentedmatlab.com</link> <description>Charting Matlab's unsupported hidden underbelly</description> <lastBuildDate>Thu, 17 May 2012 12:01:26 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.1.1</generator> <item><title>Accessing plot brushed data</title><link>http://undocumentedmatlab.com/blog/accessing-plot-brushed-data/</link> <comments>http://undocumentedmatlab.com/blog/accessing-plot-brushed-data/#comments</comments> <pubDate>Wed, 06 Oct 2010 18:00:45 +0000</pubDate> <dc:creator>Yair Altman</dc:creator> <category><![CDATA[Figure window]]></category> <category><![CDATA[Handle graphics]]></category> <category><![CDATA[Low risk of breaking in future versions]]></category> <category><![CDATA[Undocumented feature]]></category> <category><![CDATA[Callbacks]]></category> <category><![CDATA[Menubar]]></category> <category><![CDATA[Pure Matlab]]></category> <category><![CDATA[scribe]]></category> <category><![CDATA[UIInspect]]></category><guid
isPermaLink="false">http://undocumentedmatlab.com/?p=1911</guid> <description><![CDATA[Plot data brushing can be accessed programmatically using very simple pure-Matlab code<pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/controlling-plot-data-tips/' rel='bookmark' title='Controlling plot data-tips'>Controlling plot data-tips</a> <small>Data-tips are an extremely useful plotting tool that can easily be controlled programmatically....</small></li><li><a
href='http://undocumentedmatlab.com/blog/accessing-the-matlab-editor/' rel='bookmark' title='Accessing the Matlab Editor'>Accessing the Matlab Editor</a> <small>The Matlab Editor can be accessed programmatically, for a wide variety of possible uses - this article shows how....</small></li><li><a
href='http://undocumentedmatlab.com/blog/plot-liminclude-properties/' rel='bookmark' title='Plot LimInclude properties'>Plot LimInclude properties</a> <small>The plot objects' XLimInclude, YLimInclude, ZLimInclude, ALimInclude and CLimInclude properties are an important feature, that has both functional and performance implications....</small></li><li><a
href='http://undocumentedmatlab.com/blog/undocumented-scatter-plot-behavior/' rel='bookmark' title='Undocumented scatter plot behavior'>Undocumented scatter plot behavior</a> <small>The scatter plot function has an undocumented behavior when plotting more than 100 points: it returns a single unified patch object handle, rather than a patch handle for each specific...</small></li></ol><pre> </pre>]]></description> <content:encoded><![CDATA[<p>A few days ago, a reader of the Matlab Desktop blog <a
target="_blank" rel="nofollow" href="http://blogs.mathworks.com/desktop/2008/05/12/brush-up-on-your-data/#comment-7364">asked</a> whether it is possible to store plot brushed data in a separate variable for later processing. <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/help/techdoc/data_analysis/brh7_p3-1.html#brh7_p3-3">Data Brushing</a>, first introduced in R2008a, enables interactive selection and marking of plot data points. The brushed data can then be stored in a variable using the context (right-click) menu, or the figure&#8217;s Tools/Brushing menu.</p><p><center><div
class="wp-caption aligncenter" style="width: 460px"><img
alt="Saving brushed data to a variable" src="http://UndocumentedMatlab.com/images/Brushing1b.png" title="Saving brushed data to a variable" width="450" height="325" /><p
class="wp-caption-text">Saving brushed data to a variable</p></div></center></p><p>The said reader has specifically wanted programmatic access, rather than interactivity. The official answer is that data brushing was designed to be an interactive tool, and so this cannot be done. However, this has never stopped us before. So off I went to launch my favorite inspection tool, the <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/17935-uiinspect-display-methods-properties-callbacks-of-an-object">UIInspect utility</a> on the figure above (UIInspect will be described in a near-future article), which can be recreated with the following simple code:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">t=<span style="color: #33f;">0</span><span style="color: #F0F;">:</span><span style="color: #33f;">0.2</span><span style="color: #F0F;">:</span><span style="color: #33f;">25</span>; <span style="color: #0000FF;">plot</span><span style="color: #080;">&#40;</span>t,<span style="color: #0000FF;">sin</span><span style="color: #080;">&#40;</span>t<span style="color: #080;">&#41;</span>,<span style="color:#A020F0;">'.-'</span><span style="color: #080;">&#41;</span>;
<span style="color: #228B22;">% Now brush some data points...</span>
uiinspect<span style="color: #080;">&#40;</span><span style="color: #0000FF;">gca</span><span style="color: #080;">&#41;</span>;</pre></div></div><p><center><div
class="wp-caption aligncenter" style="width: 460px"><a
target="_blank" href="http://UndocumentedMatlab.com/images/Brushing2a.png"><img
alt="UIInspect-ion of a data-brushed plot" src="http://UndocumentedMatlab.com/images/Brushing2a.png" title="UIInspect-ion of a data-brushed plot" width="450" height="389" /></a><p
class="wp-caption-text">UIInspect-ion of a data-brushed plot (click for details)</p></div></center></p><p>A couple of alternative answers to the reader&#8217;s question were immediately apparent:</p><h3 id="data">Directly accessing brushed data</h3><p>First, we notice that data brushing added data-brushing context menus, both of which are called <i>BrushSeriesContextMenu</i> (the duplication is an internal Matlab bug, that does not affect usability as far as I can tell).</p><p>Also, an invisible scribe overlay axes has been added to hold the new annotations (data brushing is considered an annotation; scribe axes deserve a separate article, which they will indeed get someday).</p><p>More importantly for our needs, we see a new <i><b>line</b></i> item called &#8216;Brushing&#8217;, which displays the red lines and data points that we seek. We can now easily get the brushed data using this line&#8217;s <b>XData</b> and <b>YData</b> properties: <u>non</u>-brushed data points simply have NaN values:</p><p><center><div
class="wp-caption aligncenter" style="width: 460px"><img
alt="UIInspect-ion of the data-brushing line" src="http://UndocumentedMatlab.com/images/Brushing2b.png" title="UIInspect-ion of the data-brushing line" width="450" height="325" /><p
class="wp-caption-text">UIInspect-ion of the data-brushing line</p></div></center></p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">hBrushLine = findall<span style="color: #080;">&#40;</span><span style="color: #0000FF;">gca</span>,<span style="color:#A020F0;">'tag'</span>,<span style="color:#A020F0;">'Brushing'</span><span style="color: #080;">&#41;</span>;
brushedData = <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>hBrushLine, <span style="color: #080;">&#123;</span><span style="color:#A020F0;">'Xdata'</span>,<span style="color:#A020F0;">'Ydata'</span><span style="color: #080;">&#125;</span><span style="color: #080;">&#41;</span>;
brushedIdx = ~<span style="color: #0000FF;">isnan</span><span style="color: #080;">&#40;</span>brushedData<span style="color: #080;">&#123;</span><span style="color: #33f;">1</span><span style="color: #080;">&#125;</span><span style="color: #080;">&#41;</span>;
brushedXData = brushedData<span style="color: #080;">&#123;</span><span style="color: #33f;">1</span><span style="color: #080;">&#125;</span><span style="color: #080;">&#40;</span>brushedIdx<span style="color: #080;">&#41;</span>;
brushedYData = brushedData<span style="color: #080;">&#123;</span><span style="color: #33f;">2</span><span style="color: #080;">&#125;</span><span style="color: #080;">&#40;</span>brushedIdx<span style="color: #080;">&#41;</span>;
<span style="color: #228B22;">% and similarly for ZData in 3D plots</span></pre></div></div><h3 id="callbacks">Accessing brushing callbacks</h3><p>Yet another way of approaching the problem is to use the available callback functions built-into the data-brushing functionality. We can access either the <i>BrushSeriesContextMenu</i> or the figure&#8217;s Tools/Brushing menu. I will leave the former (context-menu) approach as an exercise to the reader, and just describe the figure&#8217;s menu approach.</p><p>As I have already explained in a <a
target="_blank" href="http://undocumentedmatlab.com/blog/modifying-default-toolbar-menubar-actions/">dedicated article</a>, figure menu-bar actions are accessible via their handles, and we can retrieve that using a unique tag (well, most of the time &#8211; read that article for details). In our case, the Tools/Brushing/Create-new-variable menu item has the unique tag &#8216;figDataManagerNewVar&#8217;. So let&#8217;s use it:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">&gt;&gt; hNewVarMenuItem = findall<span style="color: #080;">&#40;</span><span style="color: #0000FF;">gcf</span>,<span style="color:#A020F0;">'tag'</span>,<span style="color:#A020F0;">'figDataManagerNewVar'</span><span style="color: #080;">&#41;</span>
hNewVarMenuItem =
          <span style="color: #33f;">742.000244140625</span>
&nbsp;
&gt;&gt; hNewVarCallback = <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>hNewVarMenuItem,<span style="color:#A020F0;">'callback'</span><span style="color: #080;">&#41;</span>
hNewVarCallback = 
    @datamanager.<span style="">newvar</span>
&nbsp;
&gt;&gt; hNewVarCallback<span style="color: #080;">&#40;</span><span style="color: #0000FF;">gcf</span><span style="color: #080;">&#41;</span>   <span style="color: #228B22;">% activate the callback</span>
<span style="color: #228B22;">% =&gt; set 'ans' as the new variable holding the brushed data</span>
&nbsp;
&gt;&gt; <span style="color: #0000FF;">ans</span>
<span style="color: #0000FF;">ans</span> =
                       <span style="color: #33f;">6.4</span>         <span style="color: #33f;">0.116549204850494</span>
                       <span style="color: #33f;">6.6</span>         <span style="color: #33f;">0.311541363513379</span>
                       <span style="color: #33f;">6.8</span>         <span style="color: #33f;">0.494113351138609</span>
                         <span style="color: #33f;">7</span>         <span style="color: #33f;">0.656986598718789</span>
                       <span style="color: #33f;">7.2</span>         <span style="color: #33f;">0.793667863849153</span>
                       <span style="color: #33f;">7.4</span>         <span style="color: #33f;">0.898708095811627</span>
                       <span style="color: #33f;">7.6</span>         <span style="color: #33f;">0.967919672031486</span>
                       <span style="color: #33f;">7.8</span>         <span style="color: #33f;">0.998543345374605</span>
                       <span style="color: #F0F;">...</span>         <span style="color: #F0F;">...</span></pre></div></div><p>Of course, we could also have gone the hard way, via the scribe axes and the annotations route. For masochistic people like me it could even be a worthwhile challenge. But for all other normal people, why bother when there are such simple alternatives, if we only knew how to find them. <img
src='http://undocumentedmatlab.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /></p><p><pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/controlling-plot-data-tips/' rel='bookmark' title='Controlling plot data-tips'>Controlling plot data-tips</a> <small>Data-tips are an extremely useful plotting tool that can easily be controlled programmatically....</small></li><li><a
href='http://undocumentedmatlab.com/blog/accessing-the-matlab-editor/' rel='bookmark' title='Accessing the Matlab Editor'>Accessing the Matlab Editor</a> <small>The Matlab Editor can be accessed programmatically, for a wide variety of possible uses - this article shows how....</small></li><li><a
href='http://undocumentedmatlab.com/blog/plot-liminclude-properties/' rel='bookmark' title='Plot LimInclude properties'>Plot LimInclude properties</a> <small>The plot objects' XLimInclude, YLimInclude, ZLimInclude, ALimInclude and CLimInclude properties are an important feature, that has both functional and performance implications....</small></li><li><a
href='http://undocumentedmatlab.com/blog/undocumented-scatter-plot-behavior/' rel='bookmark' title='Undocumented scatter plot behavior'>Undocumented scatter plot behavior</a> <small>The scatter plot function has an undocumented behavior when plotting more than 100 points: it returns a single unified patch object handle, rather than a patch handle for each specific...</small></li></ol></p><pre> </pre>]]></content:encoded> <wfw:commentRss>http://undocumentedmatlab.com/blog/accessing-plot-brushed-data/feed/</wfw:commentRss> <slash:comments>8</slash:comments> </item> <item><title>JIDE Property Grids</title><link>http://undocumentedmatlab.com/blog/jide-property-grids/</link> <comments>http://undocumentedmatlab.com/blog/jide-property-grids/#comments</comments> <pubDate>Thu, 22 Apr 2010 00:37:52 +0000</pubDate> <dc:creator>Yair Altman</dc:creator> <category><![CDATA[Guest bloggers]]></category> <category><![CDATA[GUI]]></category> <category><![CDATA[Java]]></category> <category><![CDATA[Medium risk of breaking in future versions]]></category> <category><![CDATA[Undocumented feature]]></category> <category><![CDATA[FindJObj]]></category> <category><![CDATA[Internal component]]></category> <category><![CDATA[JIDE]]></category> <category><![CDATA[Levente Hunyadi]]></category> <category><![CDATA[Memory]]></category> <category><![CDATA[UIInspect]]></category><guid
isPermaLink="false">http://undocumentedmatlab.com/?p=1287</guid> <description><![CDATA[The JIDE components pre-bundled in Matlab enable creating user-customized property grid tables<pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/advanced-jide-property-grids/' rel='bookmark' title='Advanced JIDE Property Grids'>Advanced JIDE Property Grids</a> <small>JIDE property grids can use complex cell renderer and editor components and can signal property change events asynchronously to Matlab callbacks...</small></li><li><a
href='http://undocumentedmatlab.com/blog/plot-linesmoothing-property/' rel='bookmark' title='Plot LineSmoothing property'>Plot LineSmoothing property</a> <small>LineSmoothing is a hidden and undocumented plot line property that creates anti-aliased (smooth unpixelized) lines in Matlab plots...</small></li><li><a
href='http://undocumentedmatlab.com/blog/axes-looseinset-property/' rel='bookmark' title='Axes LooseInset property'>Axes LooseInset property</a> <small>Matlab plot axes have an undocumented LooseInset property that sets empty margins around the axes, and can be set to provide a tighter fit of the axes to their surroundings....</small></li><li><a
href='http://undocumentedmatlab.com/blog/tri-state-checkbox/' rel='bookmark' title='Tri-state checkbox'>Tri-state checkbox</a> <small>Matlab checkboxes can easily be made to support tri-state functionality....</small></li></ol><pre> </pre>]]></description> <content:encoded><![CDATA[<p><i>I would like to welcome guest blogger <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/authors/60898">Levente Hunyadi</a>.</i></p><h3>Matlab&#8217;s property inspector</h3><p>We often wish to edit properties of heterogeneous objects using a common interface. Matlab&#8217;s property inspector, invoked with the built-in <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/inspect.html"><i><b>inspect</b></i></a> function, answers this need. The inspector is based on a two-column table of property names and values. Properties and their values are populated automatically, and the user can edit values in-place. The inspector enables property categorization, sub-categorization and sorting, which help users find and modify properties easily. For each property, the inspector displays a matching edit control: editbox/combobox/checkbox etc. This simplifies property value editing and prevents illegal value entry. Matlab&#8217;s GUI builder, <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/access/helpdesk/help/techdoc/creating_guis/f7-998368.html">GUIDE</a>, uses the inspector to let users edit GUI properties such as position, color etc. It is also used by other tools such as the <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/access/helpdesk/help/techdoc/creating_plots/f9-47085.html#f9-43456">Plot Editor</a>.</p><p><center><div
class="wp-caption aligncenter" style="width: 365px"><img
alt="Matlab's built-in property inspector" src="http://UndocumentedMatlab.com/images/Inspector_mde_cropped.gif" title="Matlab's built-in property inspector" width="355" height="271" /><p
class="wp-caption-text">Matlab's built-in property inspector</p></div></center></p><p>The Matlab inspector can be embedded, with not-too-much effort, within Matlab GUI applications. Examples of this can be found in the <a
target="_blank" href="http://undocumentedmatlab.com/blog/findjobj-gui-display-container-hierarchy/">FindJObj</a> and <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/17935">UIInspect</a> utilities.</p><p><center><div
class="wp-caption aligncenter" style="width: 460px"><a
href="http://undocumentedmatlab.com/images/findjobj.png" target="_blank"><img
alt="FindJObj - embedded property inspector" src="http://undocumentedmatlab.com/images/findjobj.png" title="FindJObj - embedded property inspector" width="450" height="405" /></a><p
class="wp-caption-text">FindJObj - embedded property inspector</p></div></center></p><p>Unfortunately, Matlab&#8217;s property inspector is limited to Handle Graphics, Java and COM objects, and cannot be used for structures or user-defined Matlab classes. We shall see below how to set up our own property grid, populate it with data, and subscribe to property change events. This is a rather procedural approach. It is usually more convenient to use a declarative approach in which a structure or Matlab class is passed to a function that automatically discovers its properties and their meta-information. The <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/28732">Property Grid</a> utility at Matlab File Exchange provides these services.</p><h3 id="simple">A simple property grid</h3><p>Matlab&#8217;s property inspector is based on a property grid control by <a
target="_blank" rel="nofollow" href="http://www.jidesoft.com">JIDE Software</a>. JIDE Grids is a collection of components that extend the standard Java Swing <a
target="_blank" rel="nofollow" href="http://java.sun.com/docs/books/tutorial/uiswing/components/table.html">JTable</a> component, and is included in each Matlab installation (/java/jarext/jide/jide-grids.jar under the Matlab root). In particular, JIDE Grids includes the <em>PropertyTable</em> class, which is a fully customizable property grid component. You can find further details on JIDE Grids in the <a
target="_blank" rel="nofollow" href="http://www.jidesoft.com/products/JIDE_Grids_Developer_Guide.pdf">Developer Guide</a> and the <a
target="_blank" rel="nofollow" href="http://www.jidesoft.com/javadoc/">Javadoc documentation</a>.</p><p>There are several related classes associated with the <a
target="_blank" rel="nofollow" href="http://www.jidesoft.com/javadoc/com/jidesoft/grid/PropertyTable.html"><em>PropertyTable</em></a> class. First, a <a
target="_blank" rel="nofollow" href="http://www.jidesoft.com/javadoc/com/jidesoft/grid/PropertyTableModel.html"><em>PropertyTableModel</em></a> encapsulates all properties that are visualized in the property grid. Each property derives from the <a
target="_blank" rel="nofollow" href="http://www.jidesoft.com/javadoc/com/jidesoft/grid/Property.html"><em>Property</em></a> abstract class, which features some common actions to properties, most notably to get and set property value. <a
target="_blank" rel="nofollow" href="http://www.jidesoft.com/javadoc/com/jidesoft/grid/DefaultProperty.html"><em>DefaultProperty</em></a> is a default concrete subclass of <em>Property</em>. Finally, <a
target="_blank" rel="nofollow" href="http://www.jidesoft.com/javadoc/com/jidesoft/grid/PropertyPane.html"><em>PropertyPane</em></a> decorates a property grid with icons for changing category view to alphabetically sorted view as well as expanding and collapsing categories, and a description text box at the bottom that can be shown or hidden.</p><p>Here are the <i>DefaultProperty</i> fields and their respective roles:</p><table><tbody><tr><th>Field</th><th>Role</th></tr><tr><td>Name</td><td>Interal property name, not necessarily displayed, used as a key to identify the property.</td></tr><tr><td>DisplayName</td><td>A short property name shown in the left column of the property grid.</td></tr><tr><td>Description</td><td>A concise description of the property, shown at the bottom of the property pane, below the grid.</td></tr><tr><td>Type</td><td>The Java type associated with the property, used to invoke the appropriate renderer or editor.</td></tr><tr><td>EditorContext</td><td>An editor context object. If set, both the type and the context are used to look up the renderer or editor to use. This lets, for instance, one flag value to display as a true/false label, while another as a checkbox.</td></tr><tr><td>Category</td><td>A string specifying the property&#8217;s category, for grouping purposes.</td></tr><tr><td>Editable</td><td>Specifies whether the property value is modifiable or read-only.</td></tr><tr><td>Value</td><td>The current property value, as a Java object.</td></tr></tbody></table><p>Just as with any Java object, these fields may either be accessed with the Java get/set semantics (e.g. <i>getName()</i> or <i>setName(name)</i>), or the Matlab <i><b>get/set</b></i> semantics (e.g. <i><b>get</b>(prop,&#8217;Name&#8217;)</i> or <i><b>set</b>(prop,&#8217;Name&#8217;,name)</i>). When using the Matlab syntax, remember to wrap the Java object in a <i><b>handle()</b></i> call, to prevent a <a
target="_blank" href="http://undocumentedmatlab.com/blog/uicontrol-callbacks/#memory_leak">memory leak</a>.</p><p>To use a property grid in Matlab, first construct a set of <i>DefaultProperty</i> objects. For each object, set at least the name, type and initial value. Next, add the properties to a table model. Finally, construct a property grid with the given table model and encapsulate in a property pane:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">% Initialize JIDE's usage within Matlab</span>
com.<span style="">mathworks</span>.<span style="">mwswing</span>.<span style="">MJUtilities</span>.<span style="">initJIDE</span>;
&nbsp;
<span style="color: #228B22;">% Prepare the properties list</span>
list = java.<span style="">util</span>.<span style="">ArrayList</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>;
prop1 = com.<span style="">jidesoft</span>.<span style="color: #0000FF;">grid</span>.<span style="">DefaultProperty</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>;
prop1.<span style="">setName</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'stringProp'</span><span style="color: #080;">&#41;</span>;
prop1.<span style="">setType</span><span style="color: #080;">&#40;</span>javaclass<span style="color: #080;">&#40;</span><span style="color:#A020F0;">'char'</span>,<span style="color: #33f;">1</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
prop1.<span style="">setValue</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'initial value'</span><span style="color: #080;">&#41;</span>;
prop1.<span style="">setCategory</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'My Category'</span><span style="color: #080;">&#41;</span>;
prop1.<span style="">setDisplayName</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'Editable string property'</span><span style="color: #080;">&#41;</span>;
prop1.<span style="">setDescription</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'A concise description for my property.'</span><span style="color: #080;">&#41;</span>;
prop1.<span style="">setEditable</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">true</span><span style="color: #080;">&#41;</span>;
list.<span style="">add</span><span style="color: #080;">&#40;</span>prop1<span style="color: #080;">&#41;</span>;
&nbsp;
prop2 = com.<span style="">jidesoft</span>.<span style="color: #0000FF;">grid</span>.<span style="">DefaultProperty</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>;
prop2.<span style="">setName</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'flagProp'</span><span style="color: #080;">&#41;</span>;
prop2.<span style="">setType</span><span style="color: #080;">&#40;</span>javaclass<span style="color: #080;">&#40;</span><span style="color:#A020F0;">'logical'</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
prop2.<span style="">setValue</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">true</span><span style="color: #080;">&#41;</span>;
prop2.<span style="">setCategory</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'My Category'</span><span style="color: #080;">&#41;</span>;
prop2.<span style="">setDisplayName</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'Read-only flag property'</span><span style="color: #080;">&#41;</span>;
prop2.<span style="">setEditable</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">false</span><span style="color: #080;">&#41;</span>;
list.<span style="">add</span><span style="color: #080;">&#40;</span>prop2<span style="color: #080;">&#41;</span>;
&nbsp;
<span style="color: #228B22;">% Prepare a properties table containing the list</span>
model = com.<span style="">jidesoft</span>.<span style="color: #0000FF;">grid</span>.<span style="">PropertyTableModel</span><span style="color: #080;">&#40;</span>list<span style="color: #080;">&#41;</span>;
model.<span style="">expandAll</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">grid</span> = com.<span style="">jidesoft</span>.<span style="color: #0000FF;">grid</span>.<span style="">PropertyTable</span><span style="color: #080;">&#40;</span>model<span style="color: #080;">&#41;</span>;
pane = com.<span style="">jidesoft</span>.<span style="color: #0000FF;">grid</span>.<span style="">PropertyPane</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">grid</span><span style="color: #080;">&#41;</span>;
&nbsp;
<span style="color: #228B22;">% Display the properties pane onscreen</span>
hFig = <span style="color: #0000FF;">figure</span>;
panel = uipanel<span style="color: #080;">&#40;</span>hFig<span style="color: #080;">&#41;</span>;
javacomponent<span style="color: #080;">&#40;</span>pane, <span style="color: #080;">&#91;</span><span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">200</span> <span style="color: #33f;">200</span><span style="color: #080;">&#93;</span>, panel<span style="color: #080;">&#41;</span>;
&nbsp;
<span style="color: #228B22;">% Wait for figure window to close &amp; display the prop value</span>
uiwait<span style="color: #080;">&#40;</span>hFig<span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">disp</span><span style="color: #080;">&#40;</span>prop1.<span style="">getValue</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;</pre></div></div><p>Here, <em>com.mathworks.mwswing.MJUtilities.initJIDE</em> is called to initialize JIDE&#8217;s usage within Matlab. Without this call, we may see a JIDE warning message in some Matlab releases. We only need to <em>initJIDE</em> once per Matlab session, although there is no harm in repeated calls.</p><p><i><b>javaclass</b></i> is a function (included in the <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/28732">Property Grid</a> utility, or directly downloadable from <a
target="_blank" rel="nofollow" href="http://undocumentedmatlab.com/files/javaclass.m">here</a>) that returns a Java class for the corresponding Matlab type with the given dimension: <em><b>javaclass</b>(&#8216;logical&#8217;)</em> or <em><b>javaclass</b>(&#8216;logical&#8217;,0)</em> (a single logical flag value) returns a <em>java.lang.Boolean</em> class; <em><b>javaclass</b>(&#8216;char&#8217;,1)</em> (a character array) returns a <em>java.lang.String</em> class; <em><b>javaclass</b>(&#8216;double&#8217;,2)</em> (a matrix of double-precision floating point values) returns <em>double[][]</em>.</p><p><i><b>javacomponent</b></i> is the undocumented built-in Matlab function that adds Java Swing components to a Matlab figure, using the given dimensions and parent handle. When the user closes the figure, prop.<em>getValue()</em> fetches and displays the new property value.</p><p><center><div
class="wp-caption aligncenter" style="width: 312px"><img
alt="A simple user-defined property grid" src="http://UndocumentedMatlab.com/images/PropertyGrid_simple2.png" title="A simple user-defined property grid" width="302" height="294" /><p
class="wp-caption-text">A simple user-defined property grid</p></div></center></p><p>Next week&#8217;s article will show how to add more complex renderers and editors (display the flag value as a checkbox for example), define nested properties, and subscribe to property value change events. So stay tuned&#8230;</p><p><pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/advanced-jide-property-grids/' rel='bookmark' title='Advanced JIDE Property Grids'>Advanced JIDE Property Grids</a> <small>JIDE property grids can use complex cell renderer and editor components and can signal property change events asynchronously to Matlab callbacks...</small></li><li><a
href='http://undocumentedmatlab.com/blog/plot-linesmoothing-property/' rel='bookmark' title='Plot LineSmoothing property'>Plot LineSmoothing property</a> <small>LineSmoothing is a hidden and undocumented plot line property that creates anti-aliased (smooth unpixelized) lines in Matlab plots...</small></li><li><a
href='http://undocumentedmatlab.com/blog/axes-looseinset-property/' rel='bookmark' title='Axes LooseInset property'>Axes LooseInset property</a> <small>Matlab plot axes have an undocumented LooseInset property that sets empty margins around the axes, and can be set to provide a tighter fit of the axes to their surroundings....</small></li><li><a
href='http://undocumentedmatlab.com/blog/tri-state-checkbox/' rel='bookmark' title='Tri-state checkbox'>Tri-state checkbox</a> <small>Matlab checkboxes can easily be made to support tri-state functionality....</small></li></ol></p><pre> </pre>]]></content:encoded> <wfw:commentRss>http://undocumentedmatlab.com/blog/jide-property-grids/feed/</wfw:commentRss> <slash:comments>12</slash:comments> </item> <item><title>Accessing the Matlab Editor</title><link>http://undocumentedmatlab.com/blog/accessing-the-matlab-editor/</link> <comments>http://undocumentedmatlab.com/blog/accessing-the-matlab-editor/#comments</comments> <pubDate>Mon, 19 Oct 2009 18:00:20 +0000</pubDate> <dc:creator>Yair Altman</dc:creator> <category><![CDATA[Desktop]]></category> <category><![CDATA[High risk of breaking in future versions]]></category> <category><![CDATA[Java]]></category> <category><![CDATA[Editor]]></category> <category><![CDATA[FindJObj]]></category> <category><![CDATA[UIInspect]]></category><guid
isPermaLink="false">http://undocumentedmatlab.com/?p=671</guid> <description><![CDATA[The Matlab Editor can be accessed programmatically, for a wide variety of possible uses - this article shows how.<pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/editormacro-assign-a-keyboard-macro-in-the-matlab-editor/' rel='bookmark' title='EditorMacro &#8211; assign a keyboard macro in the Matlab editor'>EditorMacro &#8211; assign a keyboard macro in the Matlab editor</a> <small>EditorMacro is a new utility that enables setting keyboard macros in the Matlab editor. this post details its inner workings....</small></li><li><a
href='http://undocumentedmatlab.com/blog/non-textual-editor-actions/' rel='bookmark' title='Non-textual editor actions'>Non-textual editor actions</a> <small>The UIINSPECT utility can be used to expand EditorMacro capabilities to non-text-insertion actions. This is how:...</small></li><li><a
href='http://undocumentedmatlab.com/blog/accessing-plot-brushed-data/' rel='bookmark' title='Accessing plot brushed data'>Accessing plot brushed data</a> <small>Plot data brushing can be accessed programmatically using very simple pure-Matlab code...</small></li><li><a
href='http://undocumentedmatlab.com/blog/recovering-previous-editor-state/' rel='bookmark' title='Recovering previous editor state'>Recovering previous editor state</a> <small>Recovering the previous state of the Matlab editor and its loaded documents is possible using a built-in backup config file. ...</small></li></ol><pre> </pre>]]></description> <content:encoded><![CDATA[<p>Matlab&#8217;s built-in editor, like most other Matlab GUI, is Java-based. As such, it can easily be accessed programmatically. ImageAnalyst, a well-respected member of the Matlab community and a frequent CSSM (newsgroup) and FEX (File Exchange) contributor, <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/newsreader/view_thread/263329#687602">recently asked</a> whether it is possible to retrieve the name of the Editor&#8217;s currently edited file. The answer is that this is very easy, but I decided to use this opportunity to show how other interesting things can be done with the Editor.</p><p>Before we start, it should be made clear that this entire article relies on MathWorks internal implementation of the Editor and Desktop, which may change without prior notice in future Matlab releases. The code below appears to work under Matlab 6 &#038; 7, but users who rely on forward compatibility should be aware of this warning.</p><p>We start by retrieving the Editor handle. This can be done in a number of ways. The easiest is via the Matlab desktop:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #0000FF;">try</span>
    <span style="color: #228B22;">% Matlab 7</span>
    desktop = com.<span style="">mathworks</span>.<span style="">mde</span>.<span style="">desk</span>.<span style="">MLDesktop</span>.<span style="">getInstance</span>;
    jEditor = desktop.<span style="">getGroupContainer</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'Editor'</span><span style="color: #080;">&#41;</span>.<span style="">getTopLevelAncestor</span>;
    <span style="color: #228B22;">% we get a com.mathworks.mde.desk.MLMultipleClientFrame object</span>
<span style="color: #0000FF;">catch</span>
    <span style="color: #228B22;">% Matlab 6</span>
    <span style="color: #228B22;">% Unfortunately, we can't get the Editor handle from the Desktop handle in Matlab 6:</span>
    <span style="color: #228B22;">%desktop = com.mathworks.ide.desktop.MLDesktop.getMLDesktop;</span>
&nbsp;
    <span style="color: #228B22;">% So here's the workaround for Matlab 6:</span>
    openDocs = com.<span style="">mathworks</span>.<span style="">ide</span>.<span style="">editor</span>.<span style="">EditorApplication</span>.<span style="">getOpenDocuments</span>;  <span style="color: #228B22;">% a java.util.Vector</span>
    firstDoc = openDocs.<span style="">elementAt</span><span style="color: #080;">&#40;</span><span style="color: #33f;">0</span><span style="color: #080;">&#41;</span>;  <span style="color: #228B22;">% a com.mathworks.ide.editor.EditorViewContainer object</span>
    jEditor = firstDoc.<span style="">getParent</span>.<span style="">getParent</span>.<span style="">getParent</span>;
    <span style="color: #228B22;">% we get a com.mathworks.mwt.MWTabPanel or com.mathworks.ide.desktop.DTContainer object</span>
<span style="color: #0000FF;">end</span></pre></div></div><p>Now that we have the Editor handle, let&#8217;s retrieve its currently open (active) file name from the Editor&#8217;s title:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #0000FF;">title</span> = jEditor.<span style="">getTitle</span>;
currentFilename = <span style="color: #0000FF;">char</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">title</span>.<span style="">replaceFirst</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'Editor - '</span>,<span style="color:#A020F0;">''</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;</pre></div></div><p>The entire list of open file names can be retrieved in several ways:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">% Alternative #1:</span>
edhandle = com.<span style="">mathworks</span>.<span style="">mlservices</span>.<span style="">MLEditorServices</span>;
allEditorFilenames = <span style="color: #0000FF;">char</span><span style="color: #080;">&#40;</span>edhandle.<span style="">builtinGetOpenDocumentNames</span><span style="color: #080;">&#41;</span>;
&nbsp;
<span style="color: #228B22;">% Alternative #2:</span>
openFiles = desktop.<span style="">getWindowRegistry</span>.<span style="">getClosers</span>.<span style="">toArray</span>.<span style="color: #0000FF;">cell</span>;
allEditorFilenames = <span style="color: #0000FF;">cellfun</span><span style="color: #080;">&#40;</span>@<span style="color: #080;">&#40;</span>c<span style="color: #080;">&#41;</span>c.<span style="">getTitle</span>.<span style="color: #0000FF;">char</span>,openFiles,<span style="color:#A020F0;">'un'</span>,<span style="color: #33f;">0</span><span style="color: #080;">&#41;</span>;</pre></div></div><p>At the top-level Editor-window level, we can prevent its resizing, update its status bar, modify its toolbar/menu-bar, control docking and do other similar fun things:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">% Actions via built-in methods:</span>
jEditor.<span style="">setResizable</span><span style="color: #080;">&#40;</span><span style="color: #33f;">0</span><span style="color: #080;">&#41;</span>;
jEditor.<span style="">setStatusText</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'testing 123...'</span><span style="color: #080;">&#41;</span>;
jEditor.<span style="">setTitle</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'This is the Matlab Editor'</span><span style="color: #080;">&#41;</span>;
&nbsp;
<span style="color: #228B22;">% Equivalent actions via properties:</span>
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>jEditor, <span style="color:#A020F0;">'Resizable'</span>, <span style="color:#A020F0;">'off'</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>jEditor, <span style="color:#A020F0;">'StatusText'</span>, <span style="color:#A020F0;">'testing 123...'</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>jEditor, <span style="color:#A020F0;">'Title'</span>, <span style="color:#A020F0;">'This is the Matlab Editor'</span><span style="color: #080;">&#41;</span>;</pre></div></div><p>Actually, the jEditor handle has over 300 invokable methods and close to 200 properties that we can get/set. Perhaps the easiest way to find interesting things we can programmatically do with the Editor handle, is to use my <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/17935">UIInspect</a> utility on the File Exchange:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">uiinspect<span style="color: #080;">&#40;</span>jEditor<span style="color: #080;">&#41;</span>;  <span style="color: #228B22;">% or: jEditor.uiinspect</span></pre></div></div><div
class="wp-caption aligncenter" style="width: 460px"><a
href="http://undocumentedmatlab.com/images/Editor_uiinspect.png" target="_blank"><img
alt="Matlab Editor methods, callbacks and properties as seen by uiinspect (click to zoom)" src="http://undocumentedmatlab.com/images/Editor_uiinspect.png" title="Matlab Editor methods, callbacks and properties as seen by uiinspect (click to zoom)" width="450" height="403" /></a><p
class="wp-caption-text">Matlab Editor methods, callbacks and properties as seen by <b><i>uiinspect</i></b><br
/>(click to zoom)</p></div><p>The Editor handle is actually a container for many internal panels (toolbars etc.) and documents. The entire object hierarchy can be seen with another of my File Exchange utilities, <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/14317">FindJObj</a>:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">findjobj<span style="color: #080;">&#40;</span>jEditor<span style="color: #080;">&#41;</span>;  <span style="color: #228B22;">% or: jEditor.findjobj</span></pre></div></div><div
class="wp-caption aligncenter" style="width: 460px"><a
href="http://undocumentedmatlab.com/images/Editor_findjobj.png" target="_blank"><img
alt="Matlab Editor object hierarchy as seen by findjboj (click to zoom)" src="http://undocumentedmatlab.com/images/Editor_findjobj.png" title="Matlab Editor object hierarchy as seen by findjboj (click to zoom)" width="450" height="391" /></a><p
class="wp-caption-text">Matlab Editor object hierarchy as seen by <b><i>findjboj</i></b> (click to zoom)</p></div><p>We can modify text within the open Editor documents, and instrument these document to handle event callbacks. To see how, I refer users to my <a
target="_blank" href="http://undocumentedmatlab.com/blog/editormacro-assign-a-keyboard-macro-in-the-matlab-editor/">EditorMacro</a> utility on the Matlab File Exchange.</p><p>If you find some other nifty and/or useful things that can be done using the Editor handle, please post them in the comments section below.</p><p><pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/editormacro-assign-a-keyboard-macro-in-the-matlab-editor/' rel='bookmark' title='EditorMacro &#8211; assign a keyboard macro in the Matlab editor'>EditorMacro &#8211; assign a keyboard macro in the Matlab editor</a> <small>EditorMacro is a new utility that enables setting keyboard macros in the Matlab editor. this post details its inner workings....</small></li><li><a
href='http://undocumentedmatlab.com/blog/non-textual-editor-actions/' rel='bookmark' title='Non-textual editor actions'>Non-textual editor actions</a> <small>The UIINSPECT utility can be used to expand EditorMacro capabilities to non-text-insertion actions. This is how:...</small></li><li><a
href='http://undocumentedmatlab.com/blog/accessing-plot-brushed-data/' rel='bookmark' title='Accessing plot brushed data'>Accessing plot brushed data</a> <small>Plot data brushing can be accessed programmatically using very simple pure-Matlab code...</small></li><li><a
href='http://undocumentedmatlab.com/blog/recovering-previous-editor-state/' rel='bookmark' title='Recovering previous editor state'>Recovering previous editor state</a> <small>Recovering the previous state of the Matlab editor and its loaded documents is possible using a built-in backup config file. ...</small></li></ol></p><pre> </pre>]]></content:encoded> <wfw:commentRss>http://undocumentedmatlab.com/blog/accessing-the-matlab-editor/feed/</wfw:commentRss> <slash:comments>23</slash:comments> </item> <item><title>Detecting window focus events</title><link>http://undocumentedmatlab.com/blog/detecting-window-focus-events/</link> <comments>http://undocumentedmatlab.com/blog/detecting-window-focus-events/#comments</comments> <pubDate>Wed, 09 Sep 2009 20:49:51 +0000</pubDate> <dc:creator>Yair Altman</dc:creator> <category><![CDATA[Figure window]]></category> <category><![CDATA[GUI]]></category> <category><![CDATA[Hidden property]]></category> <category><![CDATA[Java]]></category> <category><![CDATA[Medium risk of breaking in future versions]]></category> <category><![CDATA[FindJObj]]></category> <category><![CDATA[JavaFrame]]></category> <category><![CDATA[UIInspect]]></category><guid
isPermaLink="false">http://undocumentedmatlab.com/?p=584</guid> <description><![CDATA[Matlab does not have any documented method to detect window focus events (gain/loss). This article describes an undocumented way to detect such events.<pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/fixing-a-java-focus-problem/' rel='bookmark' title='Fixing a Java focus problem'>Fixing a Java focus problem</a> <small>Java components added to Matlab GUIs do not participate in the standard focus cycle - this article explains how to fix this problem....</small></li><li><a
href='http://undocumentedmatlab.com/blog/udd-events-and-listeners/' rel='bookmark' title='UDD Events and Listeners'>UDD Events and Listeners</a> <small>UDD event listeners can be used to listen to property value changes and other important events of Matlab objects...</small></li><li><a
href='http://undocumentedmatlab.com/blog/matlab-callbacks-for-java-events/' rel='bookmark' title='Matlab callbacks for Java events'>Matlab callbacks for Java events</a> <small>Events raised in Java code can be caught and handled in Matlab callback functions - this article explains how...</small></li><li><a
href='http://undocumentedmatlab.com/blog/disable-entire-figure-window/' rel='bookmark' title='Enable/disable entire figure window'>Enable/disable entire figure window</a> <small>Disabling/enabling an entire figure window is impossible with pure Matlab, but is very simple using the underlying Java. This article explains how....</small></li></ol><pre> </pre>]]></description> <content:encoded><![CDATA[<p>A CSSM reader <a
target="_blank rel="nofollow" href="http://www.mathworks.com/matlabcentral/newsreader/view_thread/260078#678945">recently asked</a> whether it is possible to detect window focus events (specifically, the focus-gain event) asynchronously, so that such events can trigger a callback without necessitating a polling thread to constantly monitor the windows state.</p><p>The user correctly mentioned the fact that although mouse-clicks within the window frame can be detected using the documented figure callback <b><i>WindowButtonDownFcn</i></b>, there are other methods by which a window can gain focus: keyboard (&lt;Alt&gt;-&lt;Tab&gt; on Windows, for example), clicking the window frame edge etc. These methods are all undetected by <b><i>WindowButtonDownFcn</i></b>.</p><p>This problem is, to the best of my knowledge, insoluble using standard documented Matlab. However, there is indeed a simple solution using undocumented/unsupported Matlab features. The solution relies on the fact that all Matlab windows are basically Java Swing objects, and these objects have dozens of standard callback hooks that can be utilized (Matlab only exposes a few callbacks). The list of standard Swing callbacks was detailed in my earlier article about <a
target="_blank" href="http://undocumentedmatlab.com/blog/uicontrol-callbacks/">uicontrol callbacks</a>, which is also relevant for Java window frames.</p><p>In this specific case, we are interested in <b><i>FocusGainedCallback</i></b>. This callback is invoked for the figure Frame&#8217;s AxisComponent (a part of the Frame that will be explained in another article). For each of our monitored figure windows, we set this callback to a predefined Matlab function. We may also wish to set its companion <b><i>FocusLostCallback</i></b>.</p><p>Here&#8217;s the resulting code snippet (hFig is our Matlab figure handle):</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">% Prepare the figure</span>
hFig = <span style="color: #0000FF;">figure</span>;  <span style="color: #228B22;">% etc. - prepare the figure</span>
&nbsp;
<span style="color: #228B22;">% Get the underlying Java reference</span>
<span style="color: #0000FF;">warning</span> off MATLAB<span style="color: #F0F;">:</span>HandleGraphics<span style="color: #F0F;">:</span>ObsoletedProperty<span style="color: #F0F;">:</span>JavaFrame
jFig = <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>hFig, <span style="color:#A020F0;">'JavaFrame'</span><span style="color: #080;">&#41;</span>;
jAxis = jFig.<span style="">getAxisComponent</span>;
&nbsp;
<span style="color: #228B22;">% Set the focus event callback</span>
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>jAxis,<span style="color:#A020F0;">'FocusGainedCallback'</span>,<span style="color: #080;">&#123;</span>@myMatlabFunc,hFig<span style="color: #080;">&#125;</span><span style="color: #080;">&#41;</span>;
<span style="color: #228B22;">% perhaps also set the FocusLostCallback here</span></pre></div></div><p>Whenever any of the monitored figures now gets focus, by whichever means, the user-defined Matlab function myMatlabFunc() will be invoked. This function should be defined as follows:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #0000FF;">function</span> myMatlabFunc<span style="color: #080;">&#40;</span>jAxis, jEventData, hFig<span style="color: #080;">&#41;</span>
   <span style="color: #228B22;">% do whatever you wish with the event/hFig information</span>
<span style="color: #0000FF;">end</span></pre></div></div><p>Extra input parameters can be added during callback setup and definition, as follows:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>jAxis,<span style="color:#A020F0;">'FocusLostCallback'</span>,<span style="color: #080;">&#123;</span>@myMatlabFunc,hFig,data1,data2<span style="color: #080;">&#125;</span><span style="color: #080;">&#41;</span>
<span style="color: #F0F;">...</span>
<span style="color: #0000FF;">function</span> myMatlabFunc<span style="color: #080;">&#40;</span>jAxis, jEventData, hFig, data1, data2<span style="color: #080;">&#41;</span>
   <span style="color: #228B22;">% do whatever you wish with the event/hFig/data information</span>
<span style="color: #0000FF;">end</span></pre></div></div><p>A very similar technique can detect other windowing events (maximization/minimization/movement etc.). Depending on the case, you may need to use <i>jFig.fFigureClient.getWindow</i> instead of <i>jFig.getAxisComponent</i>. The list of available callbacks for each of these objects can be seen using a simple <i><b>set</b>(jFig.getAxisComponent)</i> command, or via my <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/17935">UIInspect</a> or <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/14317">FindJObj</a> utilities on the Matlab File Exchange.</p><p>Note that all this relies on the undocumented hidden figure property <a
target="_blank" href="http://undocumentedmatlab.com/blog/tag/javaframe/"><b><i>JavaFrame</i></b></a>, which issues a standing warning (since Matlab release R2008a) of becoming obsolete in some future Matlab release. Since it worked so far, I have turned off this warning in the code above, but note that this code may well fail in some future Matlab version. If and when JavaFrame does become obsolete, be sure to look in this blog for workarounds&#8230;</p><p><pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/fixing-a-java-focus-problem/' rel='bookmark' title='Fixing a Java focus problem'>Fixing a Java focus problem</a> <small>Java components added to Matlab GUIs do not participate in the standard focus cycle - this article explains how to fix this problem....</small></li><li><a
href='http://undocumentedmatlab.com/blog/udd-events-and-listeners/' rel='bookmark' title='UDD Events and Listeners'>UDD Events and Listeners</a> <small>UDD event listeners can be used to listen to property value changes and other important events of Matlab objects...</small></li><li><a
href='http://undocumentedmatlab.com/blog/matlab-callbacks-for-java-events/' rel='bookmark' title='Matlab callbacks for Java events'>Matlab callbacks for Java events</a> <small>Events raised in Java code can be caught and handled in Matlab callback functions - this article explains how...</small></li><li><a
href='http://undocumentedmatlab.com/blog/disable-entire-figure-window/' rel='bookmark' title='Enable/disable entire figure window'>Enable/disable entire figure window</a> <small>Disabling/enabling an entire figure window is impossible with pure Matlab, but is very simple using the underlying Java. This article explains how....</small></li></ol></p><pre> </pre>]]></content:encoded> <wfw:commentRss>http://undocumentedmatlab.com/blog/detecting-window-focus-events/feed/</wfw:commentRss> <slash:comments>24</slash:comments> </item> <item><title>Figure toolbar customizations</title><link>http://undocumentedmatlab.com/blog/figure-toolbar-customizations/</link> <comments>http://undocumentedmatlab.com/blog/figure-toolbar-customizations/#comments</comments> <pubDate>Wed, 02 Sep 2009 16:00:14 +0000</pubDate> <dc:creator>Yair Altman</dc:creator> <category><![CDATA[Figure window]]></category> <category><![CDATA[GUI]]></category> <category><![CDATA[Java]]></category> <category><![CDATA[Medium risk of breaking in future versions]]></category> <category><![CDATA[FindJObj]]></category> <category><![CDATA[Toolbar]]></category> <category><![CDATA[UIInspect]]></category><guid
isPermaLink="false">http://undocumentedmatlab.com/?p=564</guid> <description><![CDATA[Matlab's toolbars can be customized using a combination of undocumented Matlab and Java hacks. This article describes how to customize the Matlab figure toolbar.<pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/figure-toolbar-components/' rel='bookmark' title='Figure toolbar components'>Figure toolbar components</a> <small>Matlab's toolbars can be customized using a combination of undocumented Matlab and Java hacks. This article describes how to access existing toolbar icons and how to add non-button toolbar components....</small></li><li><a
href='http://undocumentedmatlab.com/blog/uicontrol-side-effect-removing-figure-toolbar/' rel='bookmark' title='uicontrol side-effect: removing figure toolbar'>uicontrol side-effect: removing figure toolbar</a> <small>Matlab's built-in uicontrol function has a side-effect of removing the figure toolbar. This was undocumented until lately. This article describes the side-effect behavior and how to fix it....</small></li><li><a
href='http://undocumentedmatlab.com/blog/uitab-customizations/' rel='bookmark' title='Uitab customizations'>Uitab customizations</a> <small>This article shows several customizations that can be done to Matlab's undocumented tab-panels functionality...</small></li><li><a
href='http://undocumentedmatlab.com/blog/modifying-default-toolbar-menubar-actions/' rel='bookmark' title='Modifying default toolbar/menubar actions'>Modifying default toolbar/menubar actions</a> <small>The default Matlab figure toolbar and menu actions can easily be modified using simple pure-Matlab code. This article explains how....</small></li></ol><pre> </pre>]]></description> <content:encoded><![CDATA[<p>Last week, I <a
target="_blank" href="http://undocumentedmatlab.com/blog/figure-toolbar-components/">described</a> how to access existing Matlab figure toolbar icons and how to add non-button toolbar components. Today, I describe how the toolbar itself can be customized using undocumented functionality and properties.</p><p>All the important undocumented customizations can only be accessed via the toolbar&#8217;s Java handle, which is retrieved so:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">hToolbar = findall<span style="color: #080;">&#40;</span>hFig,<span style="color:#A020F0;">'tag'</span>,<span style="color:#A020F0;">'FigureToolBar'</span><span style="color: #080;">&#41;</span>;
jToolbar = <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>hToolbar,<span style="color:#A020F0;">'JavaContainer'</span><span style="color: #080;">&#41;</span>,<span style="color:#A020F0;">'ComponentPeer'</span><span style="color: #080;">&#41;</span>;</pre></div></div><p>One interesting functionality is enabling a floating toolbar, via <i>jToolbar.setFloatable(1)</i>. The toolbar can then be dragged from its docked position at the top of the figure menu, becoming enclosed in an independent floating window (a non-modal javax.swing.JDialog child of the parent figure, to be exact). Since this toolbar window has a very small initial size and no name, a simple immediate fix is required:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">% Modify Java toolbar properties</span>
jToolbar.<span style="">setFloatable</span><span style="color: #080;">&#40;</span><span style="color: #33f;">1</span><span style="color: #080;">&#41;</span>;
hjToolbar = handle<span style="color: #080;">&#40;</span>jToolbar,<span style="color:#A020F0;">'CallbackProperties'</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>hjToolbar,<span style="color:#A020F0;">'AncestorAddedCallback'</span>,@dockUndockCallbackFcn<span style="color: #080;">&#41;</span>;
&nbsp;
<span style="color: #228B22;">% Sample dockUndockCallbackFcn function</span>
<span style="color: #0000FF;">function</span> dockUndockCallbackFcn<span style="color: #080;">&#40;</span>hjToolbar, eventdata<span style="color: #080;">&#41;</span>
   <span style="color: #0000FF;">if</span> hjToolbar.<span style="">isFloating</span>
      jToolbarWin = hjToolbar.<span style="">getTopLevelAncestor</span>;
      jToolbarWin.<span style="">setTitle</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'Toolbar'</span><span style="color: #080;">&#41;</span>;
      <span style="color: #228B22;">%jToolbarWin.setResizable(1); %if you wish manual resize</span>
      jToolbarWin.<span style="">setPreferredSize</span><span style="color: #080;">&#40;</span>java.<span style="">awt</span>.<span style="">Dimension</span><span style="color: #080;">&#40;</span><span style="color: #33f;">380</span>,<span style="color: #33f;">57</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
      jToolbarWin.<span style="">setSize</span><span style="color: #080;">&#40;</span>java.<span style="">awt</span>.<span style="">Dimension</span><span style="color: #080;">&#40;</span><span style="color: #33f;">380</span>,<span style="color: #33f;">57</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
      jToolbar.<span style="">revalidate</span>;  <span style="color: #228B22;">%repaint toolbar</span>
      jToolbarWin.<span style="">getParent</span>.<span style="">validate</span>; <span style="color: #228B22;">%repaint parent figure</span>
   <span style="color: #0000FF;">end</span>
<span style="color: #0000FF;">end</span></pre></div></div><p><center><div
class="wp-caption aligncenter" style="width: 425px"><img
alt="Floating toolbar" src="http://UndocumentedMatlab.com/images/toolbar5.png" title="Floating toolbar" width="102" height="118" />&nbsp;&nbsp;&nbsp;<img
alt="...and after minor fixes" src="http://UndocumentedMatlab.com/images/toolbar6.png" title="...and after minor fixes" width="307" height="118" /><p
class="wp-caption-text">Floating toolbar &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ...and after minor fixes &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;</p></div></center></p><p>Re-docking a floating toolbar can be done by simply closing the floating window – the toolbar then reappears in its default (top) position within the parent figure window.</p><p>There are other interesting functions/properties available via the Java interface – readers are encouraged to explore via the <b><i>methods</i></b>, <b><i>methodsview</i></b>, <b><i>inspect</i></b> functions, or my <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/17935">uiinspect</a> utility.</p><p>For example, <i>addGap()</i> can be used to add a transparent gap between the rightmost toolbar component and the window border: this gap is kept even if the window is shrunk to a smaller width – the rightmost components disappear, maintaining the requested gap.</p><p><i>setBackground()</i> sets the background color that is seen beneath transparent pixels of button images and gaps. Non-transparent (opaque or colored) pixels are not modified. If the button icons are improperly created, the result looks bad:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">jToolbar.<span style="">setBackground</span><span style="color: #080;">&#40;</span>java.<span style="">awt</span>.<span style="">Color</span>.<span style="">cyan</span><span style="color: #080;">&#41;</span>; <span style="color: #228B22;">%or: Color(0,1,1)</span></pre></div></div><p><center><div
class="wp-caption aligncenter" style="width: 432px"><img
alt="Default figure toolbar with cyan background" src="http://UndocumentedMatlab.com/images/toolbar9.png" title="Default figure toolbar with cyan background" width="422" height="62" /><p
class="wp-caption-text">Default figure toolbar with cyan background</p></div></center></p><p>This problem can be fixed by looping over the toolbar icons and modifying the pixel values from their default gray background to transparent. An example for this practice was given at the beginning of <a
target="_blank" href="http://undocumentedmatlab.com/blog/figure-toolbar-components/">last week&#8217;s article</a>.</p><p><i>setMorePopupEnabled()</i> is used to specify the behavior when the window resizes to such a small width that one or more toolbar buttons need to disappear – by default (=1 or true) the chevron (&gt;&gt;) mark appears on the toolbar&#8217;s right, enabling display of the missing buttons, but this behavior can be overridden (0 or false) to simply crop the extra buttons.</p><p><i>setRollover()</i> controls the behavior when the mouse passes (&#8220;rolls&#8221;) over toolbar buttons. The default parameter (1 or true), displays a 3-dimensional button border, creating an embossing effect; this can be overridden (0 or false) to use a different 3D effect:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">% Set non-default Rollover, MorePopupEnabled</span>
jToolbar.<span style="">setRollover</span><span style="color: #080;">&#40;</span><span style="color: #33f;">0</span><span style="color: #080;">&#41;</span>;         <span style="color: #228B22;">% or: set(jToolbar,'Rollover','off');</span>
jToolbar.<span style="">setMorePopupEnabled</span><span style="color: #080;">&#40;</span><span style="color: #33f;">0</span><span style="color: #080;">&#41;</span>; <span style="color: #228B22;">% or: set(jToolbar,'MorePopupEnabled','off');</span></pre></div></div><p><center><div
class="wp-caption aligncenter" style="width: 319px"><img
alt="default Rollover &#038; MorePopupEnabled properties" src="http://UndocumentedMatlab.com/images/toolbar7.png" title="default Rollover &#038; MorePopupEnabled properties" width="309" height="108" /><br/><br
/> <img
alt="non-default Rollover &#038; MorePopupEnabled properties" src="http://UndocumentedMatlab.com/images/toolbar8.png" title="non-default Rollover &#038; MorePopupEnabled properties" width="309" height="108" /><p
class="wp-caption-text">default (top) and non-default (bottom)<br/>Rollover &#038; MorePopupEnabled properties</p></div></center></p><p>Remember that toolbars are simply containers for internal components, generally buttons and separators. These components may be accessed individually and manipulated. An example of such manipulation can be found in my <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/14317">FindJObj utility</a> on the File Exchange, that lists the individual figure components: whenever the user selects a toolbar button (or any other Java component for that matter), its border is temporarily modified to a flashing red rectangle helping users understand the component&#8217;s location. Here&#8217;s the relevant code snip and screenshot (readers are encouraged to look at the actual code, which is more complex &#8211; FindJObj sub-function flashComponent()):</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">% Prepare the red border panel</span>
oldBorder = jComponent.<span style="">getBorder</span>;
redBorder = javax.<span style="">swing</span>.<span style="">border</span>.<span style="">LineBorder</span><span style="color: #080;">&#40;</span>java.<span style="">awt</span>.<span style="">Color</span>.<span style="">red</span>,<span style="color: #33f;">2</span>,<span style="color: #33f;">0</span><span style="color: #080;">&#41;</span>;
redBorderPanel = javax.<span style="">swing</span>.<span style="">JPanel</span>;
redBorderPanel.<span style="">setBorder</span><span style="color: #080;">&#40;</span>redBorder<span style="color: #080;">&#41;</span>;
redBorderPanel.<span style="">setOpaque</span><span style="color: #080;">&#40;</span><span style="color: #33f;">0</span><span style="color: #080;">&#41;</span>;  <span style="color: #228B22;">% transparent interior, red border</span>
redBorderPanel.<span style="">setBounds</span><span style="color: #080;">&#40;</span>jComponent.<span style="">getBounds</span><span style="color: #080;">&#41;</span>;
isSettable<span style="color: #080;">&#40;</span>compIdx<span style="color: #080;">&#41;</span> = ismethod<span style="color: #080;">&#40;</span>jComponent,<span style="color:#A020F0;">'setBorder'</span><span style="color: #080;">&#41;</span>;
&nbsp;
<span style="color: #228B22;">% flash by periodically displaying/hiding the panel</span>
<span style="color: #0000FF;">for</span> idx = <span style="color: #33f;">1</span> <span style="color: #F0F;">:</span> <span style="color: #33f;">2</span>*numTimes
   <span style="color: #0000FF;">if</span> idx&gt;<span style="color: #33f;">1</span>,  <span style="color: #0000FF;">pause</span><span style="color: #080;">&#40;</span>delaySecs<span style="color: #080;">&#41;</span>;  <span style="color: #0000FF;">end</span>  <span style="color: #228B22;">% don't pause at start</span>
   visible = <span style="color: #0000FF;">mod</span><span style="color: #080;">&#40;</span>idx,<span style="color: #33f;">2</span><span style="color: #080;">&#41;</span>;
   jParent = jComponent.<span style="">getParent</span>;
&nbsp;
   <span style="color: #228B22;">% Most Java components allow modifying their borders</span>
   <span style="color: #0000FF;">if</span> isSettable
      <span style="color: #0000FF;">if</span> visible
         <span style="color: #228B22;">% Set a red border</span>
         jComp.<span style="">setBorder</span><span style="color: #080;">&#40;</span>redBorder<span style="color: #080;">&#41;</span>;
         <span style="color: #0000FF;">try</span> jComponent.<span style="">setBorderPainted</span><span style="color: #080;">&#40;</span><span style="color: #33f;">1</span><span style="color: #080;">&#41;</span>; <span style="color: #0000FF;">catch</span>, <span style="color: #0000FF;">end</span>
      <span style="color: #0000FF;">else</span> <span style="color: #228B22;">%if ~isempty(oldorder)</span>
         <span style="color: #228B22;">% Remove red border by restoring the original border</span>
         jComp.<span style="">setBorder</span><span style="color: #080;">&#40;</span>oldBorder<span style="color: #080;">&#41;</span>;
      <span style="color: #0000FF;">end</span>
      jComp.<span style="">repaint</span>;
&nbsp;
   <span style="color: #228B22;">% Other Java components are highlighted by a transparent red-</span>
   <span style="color: #228B22;">% border panel, placed on top of them in their parent's space</span>
   <span style="color: #0000FF;">elseif</span> ~<span style="color: #0000FF;">isempty</span><span style="color: #080;">&#40;</span>jParent<span style="color: #080;">&#41;</span>
      <span style="color: #0000FF;">if</span> visible
         <span style="color: #228B22;">% place the transparent red-border panel on top</span>
         jParent.<span style="">add</span><span style="color: #080;">&#40;</span>redBorderPanel<span style="color: #080;">&#41;</span>;
         jParent.<span style="">setComponentZOrder</span><span style="color: #080;">&#40;</span>redBorderPanel,<span style="color: #33f;">0</span><span style="color: #080;">&#41;</span>;
      <span style="color: #0000FF;">else</span>
         jParent.<span style="">remove</span><span style="color: #080;">&#40;</span>redBorderPanel<span style="color: #080;">&#41;</span>;
      <span style="color: #0000FF;">end</span>
      jParent.<span style="">repaint</span>;
   <span style="color: #0000FF;">end</span>
<span style="color: #0000FF;">end</span>  <span style="color: #228B22;">% idx flash loop</span></pre></div></div><p><center><div
class="wp-caption aligncenter" style="width: 460px"><a
href="http://UndocumentedMatlab.com/images/findjobj.png"><img
alt="FindJObj - flashing red border around a toolbar icon" src="http://UndocumentedMatlab.com/images/findjobj.png" title="FindJObj - flashing red border around a toolbar icon" width="450" height="405" /></a><p
class="wp-caption-text">FindJObj - flashing red border around a toolbar icon</p></div></center></p><p><pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/figure-toolbar-components/' rel='bookmark' title='Figure toolbar components'>Figure toolbar components</a> <small>Matlab's toolbars can be customized using a combination of undocumented Matlab and Java hacks. This article describes how to access existing toolbar icons and how to add non-button toolbar components....</small></li><li><a
href='http://undocumentedmatlab.com/blog/uicontrol-side-effect-removing-figure-toolbar/' rel='bookmark' title='uicontrol side-effect: removing figure toolbar'>uicontrol side-effect: removing figure toolbar</a> <small>Matlab's built-in uicontrol function has a side-effect of removing the figure toolbar. This was undocumented until lately. This article describes the side-effect behavior and how to fix it....</small></li><li><a
href='http://undocumentedmatlab.com/blog/uitab-customizations/' rel='bookmark' title='Uitab customizations'>Uitab customizations</a> <small>This article shows several customizations that can be done to Matlab's undocumented tab-panels functionality...</small></li><li><a
href='http://undocumentedmatlab.com/blog/modifying-default-toolbar-menubar-actions/' rel='bookmark' title='Modifying default toolbar/menubar actions'>Modifying default toolbar/menubar actions</a> <small>The default Matlab figure toolbar and menu actions can easily be modified using simple pure-Matlab code. This article explains how....</small></li></ol></p><pre> </pre>]]></content:encoded> <wfw:commentRss>http://undocumentedmatlab.com/blog/figure-toolbar-customizations/feed/</wfw:commentRss> <slash:comments>18</slash:comments> </item> <item><title>Non-textual editor actions</title><link>http://undocumentedmatlab.com/blog/non-textual-editor-actions/</link> <comments>http://undocumentedmatlab.com/blog/non-textual-editor-actions/#comments</comments> <pubDate>Fri, 17 Jul 2009 13:55:39 +0000</pubDate> <dc:creator>Yair Altman</dc:creator> <category><![CDATA[Desktop]]></category> <category><![CDATA[High risk of breaking in future versions]]></category> <category><![CDATA[Java]]></category> <category><![CDATA[Editor]]></category> <category><![CDATA[keyboard]]></category> <category><![CDATA[UIInspect]]></category><guid
isPermaLink="false">http://undocumentedmatlab.com/?p=454</guid> <description><![CDATA[The UIINSPECT utility can be used to expand EditorMacro capabilities to non-text-insertion actions. This is how:<pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/editormacro-assign-a-keyboard-macro-in-the-matlab-editor/' rel='bookmark' title='EditorMacro &#8211; assign a keyboard macro in the Matlab editor'>EditorMacro &#8211; assign a keyboard macro in the Matlab editor</a> <small>EditorMacro is a new utility that enables setting keyboard macros in the Matlab editor. this post details its inner workings....</small></li><li><a
href='http://undocumentedmatlab.com/blog/accessing-the-matlab-editor/' rel='bookmark' title='Accessing the Matlab Editor'>Accessing the Matlab Editor</a> <small>The Matlab Editor can be accessed programmatically, for a wide variety of possible uses - this article shows how....</small></li><li><a
href='http://undocumentedmatlab.com/blog/setting-listbox-mouse-actions/' rel='bookmark' title='Setting listbox mouse actions'>Setting listbox mouse actions</a> <small>Matlab listbox uicontrol can be modified to detect mouse events for right-click context menus, dynamic tooltips etc....</small></li><li><a
href='http://undocumentedmatlab.com/blog/editormacro-v2-setting-command-window-key-bindings/' rel='bookmark' title='EditorMacro v2 &#8211; setting Command Window key-bindings'>EditorMacro v2 &#8211; setting Command Window key-bindings</a> <small>The EditorMacro utility was extended to support built-in Matlab Editor and Command-Window actions and key-bindings. This post describes the changes and the implementation details....</small></li></ol><pre> </pre>]]></description> <content:encoded><![CDATA[<p>Following my <a
href="http://undocumentedmatlab.com/blog/editormacro-assign-a-keyboard-macro-in-the-matlab-editor/" target="_blank">EditorMacro post</a> a couple of weeks ago, which showed how to assign a keyboard macro to the integrated Matlab Editor, several people have asked me whether it is possible to assign a macro to non-textual actions, in addition to the text insertion/replacement which <b><i>EditorMacro</i></b> supports.</p><p>The quick answer is yes, with some careful programming. Instead of specifying the end result, I will use this opportunity to illustrate how Java objects (not just the editor) can be inspected for their supported actions/properties.</p><p>Our first step is to get the requested Java reference handle. This can be done via the Matlab Command Window (interested readers can look at the EditorMacro.m source code, specifically at its getJEditor() function). However, a much easier way is to assign some macro using <b><i>EditorMacro</i></b> and then simply place a breakpoint in EditorMacro&#8217;s keyPressedCallback() callback function. Then press an arrow key (or any other key) in the editor, and wait for the breakpoint focus to arrive (don&#8217;t forget to clear the breakpoint&#8230;). From here on, all our actions will be done in the Command Window.</p><p>We now have a variable called jEditorPane, which is a reference to a Java object of type javahandle_withcallbacks. com.mathworks.mde.editor.EditorSyntaxTextPane (in Matlab 7 &#8211; it&#8217;s something similar in Matlab 6). This is a Matlab wrapper for the basic Java object, used for <a
href="http://undocumentedmatlab.com/blog/uicontrol-callbacks/" target="_blank">accessing the callback hooks, as explained in a previous post.</a> In our case we are not interested in this wrapper but in its wrapped object, which is retrieved via Matlab&#8217;s built-in <b><i>java</i></b> function (java(jEditorPane) or jEditorPane.java). The inspection itself is done using Matlab&#8217;s standard tools (<b><i>inspect</i></b>, <b><i>methodsview</i></b> etc.) or via my <a
href="http://www.mathworks.com/matlabcentral/fileexchange/17935" target="_blank" rel="nofollow">UIINSPECT utility</a>. I suggest using <b><i>UIINSPECT</i></b>, which displays all the information of the standard tools and lots extra, but I&#8217;m of course biased&#8230;</p><blockquote><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">uiinspect<span style="color: #080;">&#40;</span>jEditorPane.<span style="">java</span><span style="color: #080;">&#41;</span>;</pre></div></div></blockquote><p><center><div
class="wp-caption aligncenter" style="width: 460px"><a
href="http://undocumentedmatlab.com/images/uiinspect_jeditor.png" target="_blank"><img
alt="jEditorPane inspection using UIINSPECT (click to see details)" src="http://undocumentedmatlab.com/images/uiinspect_jeditor.png" title="jEditorPane inspection using UIINSPECT (click to see details)" width="450" height="355" /></a><p
class="wp-caption-text">jEditorPane inspection using <b><i>UIINSPECT</i></b> (click to see details)</p></div></center></p><p>Without diving into all the <b><i>UIINSPECT</i></b> options (I shall do this in a dedicated post), we see the supported methods/actions on the left, and properties on the right. It is true that none of them are documented, but many are self-explanatory. For example, the <i>cut()/copy()/paste()</i> methods or the <i>caretPosition/caretColor</i> properties. Any combination of these methods and properties can be used in a user-defined macro.</p><p>Let&#8217;s do a simple example, setting the &lt;Ctrl-E&gt; combination to a macro moving to the end-of-line (unix-style &#8211; equivalent to &lt;End&gt; on Windows), and &lt;Ctrl-Shift-E&gt; to a similar macro doing the same while also selecting the text (like &lt;Shift-End&gt; on Windows). We shall even use the same macro code, by simply checking in the eventData whether the &lt;Shift&gt; key is depressed:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #0000FF;">function</span> EOL_Macro<span style="color: #080;">&#40;</span>hDocument,eventData<span style="color: #080;">&#41;</span>
&nbsp;
  <span style="color: #228B22;">% Find the position of the next EOL mark</span>
  currentPos = hDocument.<span style="">getCaretPosition</span>;
  docLength = hDocument.<span style="">getLength</span>;
  textToEOF = <span style="color: #0000FF;">char</span><span style="color: #080;">&#40;</span>hDocument.<span style="">getTextStartEnd</span><span style="color: #080;">&#40;</span>currentPos,docLength<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
  nextEOLPos = currentPos+<span style="color: #0000FF;">find</span><span style="color: #080;">&#40;</span>textToEOF&lt;=<span style="color: #33f;">13</span>,<span style="color: #33f;">1</span><span style="color: #080;">&#41;</span>-<span style="color: #33f;">1</span>;  <span style="color: #228B22;">% next CR/LF pos</span>
  <span style="color: #0000FF;">if</span> <span style="color: #0000FF;">isempty</span><span style="color: #080;">&#40;</span>nextEOLPos<span style="color: #080;">&#41;</span>
      <span style="color: #228B22;">% no EOL found (=&gt; move to end-of-file)</span>
      nextEOLPos = docLength;
  <span style="color: #0000FF;">end</span>
&nbsp;
  <span style="color: #228B22;">% Do action based on whether &lt;Shift&gt; was pressed or not</span>
  <span style="color: #228B22;">%get(eventData);</span>
  <span style="color: #0000FF;">if</span> eventData.<span style="">isShiftDown</span>
      <span style="color: #228B22;">% Select to EOL</span>
      hDocument.<span style="">moveCaretPosition</span><span style="color: #080;">&#40;</span>nextEOLPos<span style="color: #080;">&#41;</span>;
  <span style="color: #0000FF;">else</span>
      <span style="color: #228B22;">% Move to EOL (without selection)</span>
      hDocument.<span style="">setCaretPosition</span><span style="color: #080;">&#40;</span>nextEOLPos<span style="color: #080;">&#41;</span>;
  <span style="color: #0000FF;">end</span>
&nbsp;
<span style="color: #0000FF;">end</span>  <span style="color: #228B22;">% EOL_Macro</span></pre></div></div><p>&#8230;and now let&#8217;s activate this macro in the Matlab Command Window:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">&gt;&gt; macros = EditorMacro<span style="color: #080;">&#40;</span><span style="color:#A020F0;">'ctrl-e'</span>,@EOL_Macro,<span style="color:#A020F0;">'run'</span><span style="color: #080;">&#41;</span>;
&gt;&gt; macros = EditorMacro<span style="color: #080;">&#40;</span><span style="color:#A020F0;">'ctrl-shift-e'</span>,@EOL_Macro,<span style="color:#A020F0;">'run'</span><span style="color: #080;">&#41;</span>
macros = 
    <span style="color:#A020F0;">'ctrl alt pressed T'</span>      @<span style="color: #080;">&#40;</span>a,b<span style="color: #080;">&#41;</span><span style="color: #0000FF;">datestr</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">now</span><span style="color: #080;">&#41;</span>    <span style="color:#A020F0;">'text'</span>
    <span style="color:#A020F0;">'ctrl pressed E'</span>          @EOL_Macro            <span style="color:#A020F0;">'run'</span> 
    <span style="color:#A020F0;">'shift ctrl pressed E'</span>    @EOL_Macro            <span style="color:#A020F0;">'run'</span></pre></div></div><p>Please do explore all the possible actions/properties exposed by the jEditorPane object. Probably the worst that could happen (and very rarely) is that you&#8217;ll crash Matlab and need to restart it &#8211; no biggy. If you find an interesting macro combination, please post it to the File Excahnge, and/or let us all know by placing a comment below.</p><p><pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/editormacro-assign-a-keyboard-macro-in-the-matlab-editor/' rel='bookmark' title='EditorMacro &#8211; assign a keyboard macro in the Matlab editor'>EditorMacro &#8211; assign a keyboard macro in the Matlab editor</a> <small>EditorMacro is a new utility that enables setting keyboard macros in the Matlab editor. this post details its inner workings....</small></li><li><a
href='http://undocumentedmatlab.com/blog/accessing-the-matlab-editor/' rel='bookmark' title='Accessing the Matlab Editor'>Accessing the Matlab Editor</a> <small>The Matlab Editor can be accessed programmatically, for a wide variety of possible uses - this article shows how....</small></li><li><a
href='http://undocumentedmatlab.com/blog/setting-listbox-mouse-actions/' rel='bookmark' title='Setting listbox mouse actions'>Setting listbox mouse actions</a> <small>Matlab listbox uicontrol can be modified to detect mouse events for right-click context menus, dynamic tooltips etc....</small></li><li><a
href='http://undocumentedmatlab.com/blog/editormacro-v2-setting-command-window-key-bindings/' rel='bookmark' title='EditorMacro v2 &#8211; setting Command Window key-bindings'>EditorMacro v2 &#8211; setting Command Window key-bindings</a> <small>The EditorMacro utility was extended to support built-in Matlab Editor and Command-Window actions and key-bindings. This post describes the changes and the implementation details....</small></li></ol></p><pre> </pre>]]></content:encoded> <wfw:commentRss>http://undocumentedmatlab.com/blog/non-textual-editor-actions/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> <item><title>GUIDE customization</title><link>http://undocumentedmatlab.com/blog/guide-customization/</link> <comments>http://undocumentedmatlab.com/blog/guide-customization/#comments</comments> <pubDate>Wed, 10 Jun 2009 17:00:43 +0000</pubDate> <dc:creator>Yair Altman</dc:creator> <category><![CDATA[GUI]]></category> <category><![CDATA[Hidden property]]></category> <category><![CDATA[High risk of breaking in future versions]]></category> <category><![CDATA[Java]]></category> <category><![CDATA[Stock Matlab function]]></category> <category><![CDATA[FindJObj]]></category> <category><![CDATA[GUIDE]]></category> <category><![CDATA[UIInspect]]></category><guid
isPermaLink="false">http://undocumentedmatlab.com/?p=383</guid> <description><![CDATA[Matlab's GUI Design Editor (GUIDE) has several interesting undocumented features. This post describes how to customize GUIDE rulers.<pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/button-customization/' rel='bookmark' title='Button customization'>Button customization</a> <small>Matlab's button uicontrols (pushbutton and togglebutton) are basically wrappers for a Java Swing JButton object. This post describes how the buttons can be customized using this Java object in ways...</small></li><li><a
href='http://undocumentedmatlab.com/blog/uitable-customization-report/' rel='bookmark' title='Uitable customization report'>Uitable customization report</a> <small>In last week&#8217;s report about uitable sorting, I offered a report that I have written which covers uitable customization in detail. Several people have asked for more details about the...</small></li><li><a
href='http://undocumentedmatlab.com/blog/findjobj-find-underlying-java-object/' rel='bookmark' title='FindJObj &#8211; find a Matlab component&#8217;s underlying Java object'>FindJObj &#8211; find a Matlab component&#8217;s underlying Java object</a> <small>The FindJObj utility can be used to access and display the internal components of Matlab controls and containers. This article explains its uses and inner mechanism....</small></li><li><a
href='http://undocumentedmatlab.com/blog/uitable-sorting/' rel='bookmark' title='Uitable sorting'>Uitable sorting</a> <small>Matlab's uitables can be sortable using simple undocumented features...</small></li></ol><pre> </pre>]]></description> <content:encoded><![CDATA[<p>GUIDE is the acronym for Matlab&#8217;s Graphical User Interface Design Editor. It is very handy for designing simple GUI figures, although my experience has shown that it has limitations for complex GUIs. Nevertheless, GUIDE is the tool used by most Matlab developers when designing GUIs. In this post, I will show a few undocumented customizations that could help make GUIDE sessions more productive.</p><p>The starting point is GUIDE&#8217;s undocumented return value, which is a Java reference to the Layout Editor panel within the GUIDE figure frame:</p><blockquote><pre>
<span style="color: #000000;">&gt;&gt; h = guide</span>
h =
Layout Document [untitled]

<span style="color: #000000;">&gt;&gt; h.getClass</span>
ans =
class com.mathworks.toolbox.matlab.guide.LayoutEditor
</pre></blockquote><p>This return handle can be used to access GUIDE components and functionality. We can start by inspecting the interesting GUIDE layout hierarchy using my <a
rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/fileexchange/14317">FindJObj utility</a>, and the associated properties and method using my <a
rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/fileexchange/17935">UIInspect utility</a>:</p><blockquote><pre><span style="color: #000000;">&gt;&gt; h.findjobj;
&gt;&gt; h.uiinspect;
</span></pre></blockquote><p><center><div
class="wp-caption aligncenter" style="width: 460px"><img
alt="Hierarchy of Layout Editor within the GUIDE frame" src="http://undocumentedmatlab.com/images/guide_ruler1.png" title="Hierarchy of Layout Editor within the GUIDE frame" width="450" height="351" /><p
class="wp-caption-text">Hierarchy of Layout Editor within the GUIDE frame</p></div></center></p><p>Note: If you wish to see the hierarchy of the entire GUIDE figure frame, simply run FindJObj on the frame reference, by either of the two following methods (and similarly for UIInspect):</p><blockquote><pre><span style="color: #000000;">&gt;&gt; findjobj(h.getFrame);
&gt;&gt; findjobj(h.getTopLevelWindow);
</span></pre></blockquote><p>We see that the Layout Editor contains, in addition to the expected LayoutArea and two MWScrollbars, several objects that relate to a ruler. These rulers can be activated via the GUIDE menu (Tools / Grid and Rulers), or via the Matlab Command Prompt as described below:</p><p>Looking at the ruler properties in FindJObj or UIInspect, we can see a settable boolean property called &#8220;RulerState&#8221;. If we turn it on we can see that a very handy pixels-ruler appears. Once we set this property, it remains in effect for every future GUIDE session:</p><p><center><div
class="wp-caption aligncenter" style="width: 440px"><img
alt="Before: GUIDE with no rulers" src="http://undocumentedmatlab.com/images/guide_ruler2.png" title="Before: GUIDE with no rulers" width="430" height="286" /><p
class="wp-caption-text">Before: GUIDE with no rulers</p></div></center></p><blockquote><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">h.<span style="">getComponent</span><span style="color: #080;">&#40;</span><span style="color: #33f;">0</span><span style="color: #080;">&#41;</span>.<span style="">getComponent</span><span style="color: #080;">&#40;</span><span style="color: #33f;">4</span><span style="color: #080;">&#41;</span>.<span style="">setRulerState</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">true</span><span style="color: #080;">&#41;</span>;  <span style="color: #228B22;">% Horizontal</span>
h.<span style="">getComponent</span><span style="color: #080;">&#40;</span><span style="color: #33f;">0</span><span style="color: #080;">&#41;</span>.<span style="">getComponent</span><span style="color: #080;">&#40;</span><span style="color: #33f;">5</span><span style="color: #080;">&#41;</span>.<span style="">setRulerState</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">true</span><span style="color: #080;">&#41;</span>;  <span style="color: #228B22;">% Vertical</span></pre></div></div></blockquote><p>Note: RulerState actually controls a system preference (LayoutShowRulers, a boolean flag) that controls the visibility of both rulers, and persists across Matlab/GUIDE sessions.  To change the visibility of only a single ruler for this GUIDE session only, or on old Matlab versions (e.g. Matlab 7.1 aka R14 SP3) that do not have the &#8216;RulerState&#8217; property, use the hide()/show()/setVisible(flag) methods, or set the &#8216;Visible&#8217; property:</p><blockquote><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">% Equivalent ways to show horizontal ruler for this GUIDE session only</span>
hRuler = h.<span style="">getComponent</span><span style="color: #080;">&#40;</span><span style="color: #33f;">0</span><span style="color: #080;">&#41;</span>.<span style="">getComponent</span><span style="color: #080;">&#40;</span><span style="color: #33f;">4</span><span style="color: #080;">&#41;</span>;  <span style="color: #228B22;">% =top horizontal ruler</span>
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>hRuler, <span style="color:#A020F0;">'Visible'</span>,<span style="color:#A020F0;">'on'</span><span style="color: #080;">&#41;</span>;
hRuler.<span style="">setVisible</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">true</span><span style="color: #080;">&#41;</span>;  <span style="color: #228B22;">% or: hRuler.setVisible(1)</span>
hRuler.<span style="">show</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>;</pre></div></div></blockquote><p><center><div
class="wp-caption aligncenter" style="width: 440px"><img
alt="After: GUIDE with pixel rulers" src="http://undocumentedmatlab.com/images/guide_ruler3.png" title="After: GUIDE with pixel rulers" width="430" height="286" /><p
class="wp-caption-text">After: GUIDE with pixel rulers</p></div></center></p><p>Using this method, we can customize the rulers &#8211; options which are unavailable using the standard GUIDE menu options: We can specify horizontal/vertical grid size, tick &#038; label interval and similar ruler properties. For example, let&#8217;s set a 5-pixel minor tick interval, 25-pixel major interval, labels every 50 pixels, starting offset of 40 pixels and a ruler size limited at 260 pixels:</p><blockquote><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">hRuler = h.<span style="">getComponent</span><span style="color: #080;">&#40;</span><span style="color: #33f;">0</span><span style="color: #080;">&#41;</span>.<span style="">getComponent</span><span style="color: #080;">&#40;</span><span style="color: #33f;">4</span><span style="color: #080;">&#41;</span>;  <span style="color: #228B22;">% =top horizontal ruler</span>
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>hRuler, <span style="color:#A020F0;">'MinorInterval'</span>,<span style="color: #33f;">5</span>, <span style="color:#A020F0;">'MajorInterval'</span>,<span style="color: #33f;">25</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>hRuler, <span style="color:#A020F0;">'LabelInterval'</span>,<span style="color: #33f;">50</span>, <span style="color:#A020F0;">'LabelUnit'</span>,<span style="color: #33f;">50</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>hRuler, <span style="color:#A020F0;">'Margin'</span>,<span style="color: #33f;">40</span>, <span style="color:#A020F0;">'Length'</span>,<span style="color: #33f;">260</span><span style="color: #080;">&#41;</span>;</pre></div></div></blockquote><p><center><div
class="wp-caption aligncenter" style="width: 440px"><img
alt="GUIDE with modified pixel rulers" src="http://undocumentedmatlab.com/images/guide_ruler4.png" title="GUIDE with modified pixel rulers" width="430" height="286" /><p
class="wp-caption-text">GUIDE with modified pixel rulers</p></div></center></p><p>Note that the vertical ruler&#8217;s labels start (=LabelStart property) at the figure&#8217;s height, and have a <em>decreasing</em> LabelInterval of -50. This is done because Java coordinates start counting from the top-left corner <em>downward</em>, whereas Matlab counts from the bottom-left <em>upward</em>. In GUIDE, we naturally wish to display the Matlab coordinates, hence the transformation.</p><p>Note: unfortunately, most of these properties do not have equivalent settable system properties that I could find. Here is a list of all the GUIDE-related system properties that I found:</p><ul><li><strong>LayoutShowRulers</strong> &#8211; boolean, controls display of both rulers</li><li><strong>LayoutShowGuides</strong> &#8211; boolean, controls display of blue guidelines</li><li><strong>LayoutShowGrid</strong> &#8211; boolean, controls display of gray gridlines</li><li><strong>LayoutGridWidth</strong> &#8211; integer, controls the size of the grid boxes</li><li><strong>LayoutSnapToGrid</strong> &#8211; boolean, controls snap-to-grid behavior</li><li><strong>LayoutActivate</strong> &#8211; boolean, controls ability to run (activate) unsaved figures without confirmation</li><li><strong>LayoutChangeDefaultCallback</strong> &#8211; boolean, ??? (I can see this preference in my matlab.prf file but I have no idea what it does or how it got there&#8230;)</li><li><strong>LayoutExport</strong> &#8211; boolean, controls ability to export unsaved figures without confirmation</li><li><strong>LayoutExtension</strong> &#8211; boolean, controls display of file extension in the GUIDE window title</li><li><strong>LayoutFullPath</strong> &#8211; boolean, controls display of file path in the GUIDE window title</li><li><strong>LayoutMCodeComments</strong> &#8211; boolean, controls generation of comments for m-file callbacks</li><li><strong>LayoutToolBar</strong> &#8211; boolean, controls display of the GUIDE widow toolbar</li><li><strong>LayoutToolNames</strong> &#8211; boolean, controls display of tool names in the components palette</li></ul><p>Have you discovered other undocumented features in GUIDE? If so, please share your findings in the comments section below.</p><p><strong><u>Warning</u></strong>: These undocumented features are way deep in unsupported territory. They depend heavily on Matlab&#8217;s internal implementation, which may change without any prior notice between Matlab releases. They work ok on Matlab versions 7.1 (R14 SP3) through 7.6 (R2008a), and perhaps on other versions as well. However, the very next Matlab release might break these features, so beware.</p><p><pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/button-customization/' rel='bookmark' title='Button customization'>Button customization</a> <small>Matlab's button uicontrols (pushbutton and togglebutton) are basically wrappers for a Java Swing JButton object. This post describes how the buttons can be customized using this Java object in ways...</small></li><li><a
href='http://undocumentedmatlab.com/blog/uitable-customization-report/' rel='bookmark' title='Uitable customization report'>Uitable customization report</a> <small>In last week&#8217;s report about uitable sorting, I offered a report that I have written which covers uitable customization in detail. Several people have asked for more details about the...</small></li><li><a
href='http://undocumentedmatlab.com/blog/findjobj-find-underlying-java-object/' rel='bookmark' title='FindJObj &#8211; find a Matlab component&#8217;s underlying Java object'>FindJObj &#8211; find a Matlab component&#8217;s underlying Java object</a> <small>The FindJObj utility can be used to access and display the internal components of Matlab controls and containers. This article explains its uses and inner mechanism....</small></li><li><a
href='http://undocumentedmatlab.com/blog/uitable-sorting/' rel='bookmark' title='Uitable sorting'>Uitable sorting</a> <small>Matlab's uitables can be sortable using simple undocumented features...</small></li></ol></p><pre> </pre>]]></content:encoded> <wfw:commentRss>http://undocumentedmatlab.com/blog/guide-customization/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> <item><title>Uicontrol callbacks</title><link>http://undocumentedmatlab.com/blog/uicontrol-callbacks/</link> <comments>http://undocumentedmatlab.com/blog/uicontrol-callbacks/#comments</comments> <pubDate>Fri, 01 May 2009 09:58:16 +0000</pubDate> <dc:creator>Yair Altman</dc:creator> <category><![CDATA[GUI]]></category> <category><![CDATA[Java]]></category> <category><![CDATA[Low risk of breaking in future versions]]></category> <category><![CDATA[UI controls]]></category> <category><![CDATA[Callbacks]]></category> <category><![CDATA[FindJObj]]></category> <category><![CDATA[uicontrol]]></category> <category><![CDATA[UIInspect]]></category><guid
isPermaLink="false">http://undocumentedmatlab.com/?p=223</guid> <description><![CDATA[This post details undocumented callbacks exposed by the underlying Java object of Matlab uicontrols, that can be used to modify the control's behavior in a multitude of different events<pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/additional-uicontrol-tooltip-hacks/' rel='bookmark' title='Additional uicontrol tooltip hacks'>Additional uicontrol tooltip hacks</a> <small>Matlab's uicontrol tooltips have several limitations that can be overcome using the control's underlying Java object....</small></li><li><a
href='http://undocumentedmatlab.com/blog/setting-line-position-in-edit-box-uicontrol/' rel='bookmark' title='Setting line position in an edit-box uicontrol'>Setting line position in an edit-box uicontrol</a> <small>Matlab uicontrols have many useful features that are only available via Java. Here's how to access them....</small></li><li><a
href='http://undocumentedmatlab.com/blog/uisplittool-uitogglesplittool-callbacks/' rel='bookmark' title='uisplittool &amp; uitogglesplittool callbacks'>uisplittool &#038; uitogglesplittool callbacks</a> <small>Matlab's undocumented uisplittool and uitogglesplittool are powerful toolbar controls - this article explains how to customize their behavior...</small></li><li><a
href='http://undocumentedmatlab.com/blog/matlab-callbacks-for-java-events/' rel='bookmark' title='Matlab callbacks for Java events'>Matlab callbacks for Java events</a> <small>Events raised in Java code can be caught and handled in Matlab callback functions - this article explains how...</small></li></ol><pre> </pre>]]></description> <content:encoded><![CDATA[<p>In my previous post I showed how we can <a
target="_blank" href="http://undocumentedmatlab.com/blog/button-customization/">extensively customize a Matlab uicontrol&#8217;s appearance and behavior</a> by accessing its undocumented underlying Java object. In this post I will show how to further customize the control&#8217;s behavior using the callbacks exposed by its underlying object.</p><p>Matlab&#8217;s uicontrol handles normally expose only a few event callbacks. These are &#8216;CreateFcn&#8217;, &#8216;DeleteFcn&#8217;, &#8216;ButtonDownFcn&#8217;, &#8216;KeyPressFcn&#8217; and the control-specific &#8216;Callback&#8217;. In contrast, the underlying Java control exposes many more callbacks: 26 standard callbacks, plus a few control-specific callbacks, as follows:</p><ul><li><b>AncestorMovedCallback</b> – fired when one of the component&#8217;s container ancestors has changed its position relative to its container.</li><li><b>AncestorAddedCallback</b> – fired when one of the component&#8217;s container ancestors has been added to another container</li><li><b>AncestorRemovedCallback</b> – fired when one of the component&#8217;s container ancestors has been removed from the component&#8217;s hierarchy</li><li><b>AncestorResizedCallback</b> – fired when one of the component&#8217;s container ancestor has been resized</li><li><b>ComponentAddedCallback</b> – fired when a sub-component is added as a direct child to this component.  Compare: ComponentRemovedCallback</li><li><b>ComponentHiddenCallback</b> – fired when the component is hidden (<i>setVisible(false)</i>).  Compare: ComponentShownCallback</li><li><b>ComponentMovedCallback</b> – fired when the component is moved within its container. Since Java components are enclosed in a tight-fitting HG container, this callback will never fire for them: it does not fire when the container moves or resizes, only when the component&#8217;s starting position is moved within it.</li><li><b>ComponentRemovedCallback</b> – fired when a sub-component is added as a direct child to this component. Compare: ComponentAddedCallback</li><li><b>ComponentResizedCallback</b> – fired when the component is resized, either directly or because its container was resized.</li><li><b>ComponentShownCallback</b> – fired when the component is displayed (<i>setVisible(true)</i>). Compare: ComponentHiddenCallback</li><li><b>FocusGainedCallback</b> – fired when the component gains GUI focus,  by mouse click, Tab click, or calling the component&#8217;s <i>requestFocus()</i> method.</li><li><b>FocusLostCallback</b> – fired when the component loses focus to another component or window. Compare: FocusGainedCallback</li><li><b>HierarchyChangedCallback</b> – fired when the component changes its ancestors (for example, moved from one panel to another).</li><li><b>KeyPressedCallback</b> – fired continuously when any keyboard button (including Shift, Ctrl etc.) was pressed while the component had focus.  The meta-data contains details about the specific key and modifiers (Alt, Shift, Ctrl, …) that were pressed.  Compare: KeyReleasedCallback, KeyTypedCallback</li><li><b>KeyReleasedCallback</b> – fired when a keyboard button was released while the component had focus. The meta-data contains details about the specific key and modifiers (Alt, Shift, Ctrl, …) that were pressed. Compare: KeyPressedCallback</li><li><b>KeyTypedCallback</b> – similar to KeyPressedCallback, but only fired (continuously) when an actual printable character is clicked. Therefore, for Shift-A, KeyPressedCallback will fire twice (Shift, &#8216;A&#8217;) but KeyTypedCallback will only fire once. Compare: KeyPressedCallback, KeyReleasedCallback</li><li><b>MouseClickedCallback</b> – fired when a mouse button is pressed and then released (=clicked) within the component&#8217;s bounds. If either the press or the release occurs outside the component&#8217;s bounds, the event will not fire. The figure&#8217;s &#8216;SelectionType&#8217; property  will be &#8216;normal&#8217;, &#8216;extend&#8217; or &#8216;alt&#8217; depending on which button was pressed. Compare: MousePressedCallback, MouseReleasedCallback.</li><li><b>MouseDraggedCallback</b> – fired continuously when the mouse is clicked within the component&#8217;s bounds and then moved while the button is still depressed (i.e., dragged), even beyond the component&#8217;s bounds.  The callback event&#8217;s meta-data will contain the delta-x and delta-y of the movement (positive for x-right/y-down; negative for x-left/y-up). Compare: MouseMovedCallback</li><li><b>MouseEnteredCallback</b> – fired when the mouse is moved (depressed or not) into the component&#8217;s bounds. Compare: MouseExitedCallback</li><li><b>MouseExitedCallback</b> – fired when the mouse is moved (depressed or not) out of the component&#8217;s bounds. Compare: MouseEnteredCallback</li><li><b>MouseMovedCallback</b> – fired continuously when the mouse is moved undepressed within the component&#8217;s bounds. The callback event&#8217;s meta-data will contain the delta-x and delta-y of the movement (positive for x-right/y-down; negative for x-left/y-up). Compare: MouseDraggedCallback</li><li><b>MousePressedCallback</b> – fired immediately when the mouse button is depressed (even before it was released) within the component&#8217;s bounds.  The callback event&#8217;s meta-data will contain the click location within the component&#8217;s bounds. Compare: MouseClickedCallback, MouseReleasedCallback</li><li><b>MouseReleasedCallback</b> – fired immediately when the mouse button is released within the component&#8217;s bounds.  The callback event&#8217;s meta-data will contain the click location within the component&#8217;s bounds. Compare: MousePressedCallback</li><li><b>MouseWheelMovedCallback</b> – fired immediately when the mouse wheel is turned (even before it was released) within the component&#8217;s bounds.</li><li><b>PropertyChangeCallback</b> – fired when one of the component&#8217;s properties has changed. For example, after setting the component&#8217;s text, tooltip or border. Does not fire when modifying the component&#8217;s callback properties.</li><li><b>VetoableChangeCallback</b> – fired upon a constrained property value change, allowing the callback to intercept and prevent the property change by raising an exception. Of all the Swing components, only JInternalFrame actually declares vetoable properties which can be intercepted.</li></ul><p>It should be noted that these callbacks are standard in all Swing GUI controls. Thus, they can be used not just for Matlab uicontrols&#8217; underlying Java objects, but also for any Swing component that you display using Matlab&#8217;s built-in <b><i>javacomponent</i></b> function.</p><p>The specific list of callbacks supported by each component depends on component type. As noted above, some components have additional specific callbacks.  For example, ActionPerformedCallback is fired when a user has performed the main action associated with the control (selecting/clicking etc.).  This is one of the most commonly used callbacks, one of the few exposed by Matlab HG handles (as the general-purpose &#8216;Callback&#8217;). This callback is implemented by JButton and JCheckBox (for instance), but not by JList or JMenu. CaretUpdateCallback and CaretPositionChangedCallback  are only supported by text-entry controls like JTextField or JEditorPane, but not by JSlider or JTabbedPane. Other components have other such specific callbacks.</p><p>To see the full list of supported callbacks for a particular object, use the <a
rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/17935" target="_blank">UIINSPECT utility from the File Exchange</a> or use the following code snippet:</p><blockquote><pre><span style="color: #000000">>> props = sort(fieldnames(get(javax.swing.JButton)));
>> callbackNames = props(~cellfun(@isempty,regexp(props,</span><span style="color: #800080">'Callback$'</span>)));
callbackNames =
    'ActionPerformedCallback'
    'AncestorAddedCallback'
    'AncestorMovedCallback'
    ...
</pre></blockquote><p>A nice example of using Java callbacks to automatically select (highlight) the content text in a text-box when focus is gained was <a
rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/newsreader/view_thread/80041#204096">one of the first online posts in CSSM to use Matlab 7&#8242;s new javacomponent Swing integration</a>.</p><p>Another typical usage is to <a
rel="nofollow" target="_blank" href="http://www.mathworks.com/matlabcentral/newsreader/view_thread/144980">set a continuously-firing callback whenever a slider uicontrol is dragged</a> &#8211; the Matlab HG callback only fires once after the drag has completed, whereas we often wish to update some value or graphics <i>during</i> the drag events. This can easily be done using JSlider&#8217;s underlying object (a Swing JScrollBar) callbacks.</p><p><a
name="memory_leak"></a><br
/> In order to <a
target="_blank" rel="nofollow" href="http://mathforum.org/kb/message.jspa?messageID=5950839">prevent memory leaks</a> in heavily-laden GUIs, it is advisable to get and set callback properties using the <b><i>handle</i></b> object, instead of directly on the &#8220;naked&#8221; Java reference. For this reason, using <b><i>set/get</i></b> is <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/set.html#f67-433534">discouraged by MathWorks</a> and may even be <a
target="_blank" rel="nofollow" href="http://www.mathworks.com/access/helpdesk/help/techdoc/rn/broifyr-1.html#brrxpv8-1">disabled in some future Matlab release</a>:</p><blockquote><pre><span style="color: #000000">jb = javax.swing.JButton;
jbh = handle(jb,</span><span style="color: #800080">'CallbackProperties'</span><span style="color: #000000">);
</span><span style="color: #008000">% or for an existing uicontrol: jbh = findjobj(hButton);</span><span style="color: #000000">
set(jbh, </span><span style="color: #800080">'ActionPerformedCallback'</span><span style="color: #000000">,@myCallbackFcn)  </span><span style="color: #008000">% ok!</span><span style="color: #000000">
set(jb,  </span><span style="color: #800080">'ActionPerformedCallback'</span><span style="color: #000000">,@myCallbackFcn)  </span><span style="color: #008000">% bad! memory leak</span>
</pre></blockquote><p>In some future post I plan to present more details about <b><i>handle()</i></b> and its intricacies. But in a nutshell, this code snippet is all you need to start working.</p><p>Callbacks can be set in the normal Matlab fashion, using one of three methods:</p><blockquote><pre><span style="color: #000000">set(jbh, </span><span style="color: #800080">'ActionPerformedCallback'</span><span style="color: #000000">,@myCallbackFcn);
set(jbh, </span><span style="color: #800080">'ActionPerformedCallback'</span><span style="color: #000000">,{@myCallbackFcn,param1,param2});
set(jbh, </span><span style="color: #800080">'ActionPerformedCallback','disp(123);'</span><span style="color: #000000">);</span></pre></blockquote><p>I would be happy to hear how you use these newly-exposed callbacks in your application. Please leave your welcome comments below.</p><p><pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/additional-uicontrol-tooltip-hacks/' rel='bookmark' title='Additional uicontrol tooltip hacks'>Additional uicontrol tooltip hacks</a> <small>Matlab's uicontrol tooltips have several limitations that can be overcome using the control's underlying Java object....</small></li><li><a
href='http://undocumentedmatlab.com/blog/setting-line-position-in-edit-box-uicontrol/' rel='bookmark' title='Setting line position in an edit-box uicontrol'>Setting line position in an edit-box uicontrol</a> <small>Matlab uicontrols have many useful features that are only available via Java. Here's how to access them....</small></li><li><a
href='http://undocumentedmatlab.com/blog/uisplittool-uitogglesplittool-callbacks/' rel='bookmark' title='uisplittool &amp; uitogglesplittool callbacks'>uisplittool &#038; uitogglesplittool callbacks</a> <small>Matlab's undocumented uisplittool and uitogglesplittool are powerful toolbar controls - this article explains how to customize their behavior...</small></li><li><a
href='http://undocumentedmatlab.com/blog/matlab-callbacks-for-java-events/' rel='bookmark' title='Matlab callbacks for Java events'>Matlab callbacks for Java events</a> <small>Events raised in Java code can be caught and handled in Matlab callback functions - this article explains how...</small></li></ol></p><pre> </pre>]]></content:encoded> <wfw:commentRss>http://undocumentedmatlab.com/blog/uicontrol-callbacks/feed/</wfw:commentRss> <slash:comments>26</slash:comments> </item> <item><title>Button customization</title><link>http://undocumentedmatlab.com/blog/button-customization/</link> <comments>http://undocumentedmatlab.com/blog/button-customization/#comments</comments> <pubDate>Fri, 24 Apr 2009 15:51:04 +0000</pubDate> <dc:creator>Yair Altman</dc:creator> <category><![CDATA[GUI]]></category> <category><![CDATA[High risk of breaking in future versions]]></category> <category><![CDATA[Java]]></category> <category><![CDATA[UI controls]]></category> <category><![CDATA[FindJObj]]></category> <category><![CDATA[uicontrol]]></category> <category><![CDATA[UIInspect]]></category><guid
isPermaLink="false">http://undocumentedmatlab.com/?p=184</guid> <description><![CDATA[Matlab's button uicontrols (pushbutton and togglebutton) are basically wrappers for a Java Swing JButton object. This post describes how the buttons can be customized using this Java object in ways that are impossible using pure Matlab.<pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/borderless-button-used-for-plot-properties/' rel='bookmark' title='Borderless button used for plot properties'>Borderless button used for plot properties</a> <small>A borderless button can be used to add unobtrusive functionality to plot axes...</small></li><li><a
href='http://undocumentedmatlab.com/blog/guide-customization/' rel='bookmark' title='GUIDE customization'>GUIDE customization</a> <small>Matlab's GUI Design Editor (GUIDE) has several interesting undocumented features. This post describes how to customize GUIDE rulers....</small></li><li><a
href='http://undocumentedmatlab.com/blog/uitable-customization-report/' rel='bookmark' title='Uitable customization report'>Uitable customization report</a> <small>In last week&#8217;s report about uitable sorting, I offered a report that I have written which covers uitable customization in detail. Several people have asked for more details about the...</small></li><li><a
href='http://undocumentedmatlab.com/blog/findjobj-gui-display-container-hierarchy/' rel='bookmark' title='FindJObj GUI &#8211; display container hierarchy'>FindJObj GUI &#8211; display container hierarchy</a> <small>The FindJObj utility can be used to present a GUI that displays a Matlab container's internal Java components, properties and callbacks....</small></li></ol><pre> </pre>]]></description> <content:encoded><![CDATA[<p>Matlab&#8217;s button uicontrols (pushbutton and togglebutton) are basically wrappers for a Java Swing <a
rel="nofollow" href="http://java.sun.com/docs/books/tutorial/uiswing/components/button.html" target="_blank">JButton</a> object.</p><p>This will be the first in a series of posts showing how Matlab uicontrols can be customized in ways that you may never have thought possible.</p><p>Probably the simplest undocumented customization is the control&#8217;s <a
href="http://undocumentedmatlab.com/blog/html-support-in-matlab-uicomponents/" target="_blank">acceptance of HTML and CSS Strings</a>:</p><blockquote><pre><span style="color: #000000;">tooltip = </span><span style="color: #800080;">'&lt;html&gt;HTML-aware&lt;br&gt;&lt;b&gt;tooltips&lt;/b&gt;&lt;br&gt;&lt;i&gt;supported'</span><span style="color: #000000;">;
labelTop= </span><span style="color: #800080;">'&lt;HTML&gt;&lt;center&gt;&lt;FONT color="red"&gt;Hello&lt;/Font&gt; &lt;b&gt;world&lt;/b&gt;'</span><span style="color: #000000;">;
labelBot=[</span><span style="color: #800080;">'&lt;div style="font-family:impact;color:green"&gt;&lt;i&gt;What a&lt;/i&gt;'...
          ' &lt;Font color="blue" face="Comic Sans MS"&gt;nice day!'</span><span style="color: #000000;">];
set(hButton, </span><span style="color: #800080;">'tooltip'</span><span style="color: #000000;">,tooltip, </span><span style="color: #800080;">'string'</span><span style="color: #000000;">,[labelTop </span><span style="color: #800080;">'&lt;br&gt;'</span><span style="color: #000000;"> labelBot]);</span></pre></blockquote><p><center><div
id="attachment_194" class="wp-caption aligncenter" style="width: 174px"><img
class="size-full wp-image-194" title="button_html" src="http://undocumentedmatlab.com/blog/wp-content/uploads/2009/04/button_html.png" alt="Button with HTML label and tooltip" width="164" height="78" /><p
class="wp-caption-text">Button with HTML label and tooltip</p></div></center></p><p>For more powerful customization, we need to access the control&#8217;s underlying JList object. We do this by using my <a
rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/14317" target="_blank">FindJObj submission on the File Exchange</a> (which was explained <a
target="_blank" href="http://undocumentedmatlab.com/blog/findjobj-find-underlying-java-object/">here</a>):</p><blockquote><pre><span style="color: #000000;">&gt;&gt; jButton = java(findjobj(hButton))</span>
jButton =
com.mathworks.hg.peer.PushButtonPeer$1[,0,0,...]
</pre></blockquote><p>Now that we have the jButton Java object reference, we can use <b><em>get</em></b> and <b><em>set</em></b> just like any Matlab handle. To see the list of all available properties, methods and callbacks, we can use my <a
rel="nofollow" href="http://www.mathworks.com/matlabcentral/fileexchange/17935" target="_blank">UIINSPECT submission on the File Exchange</a>, or use Matlab&#8217;s built-in <b><em>methodsview</em></b> function.</p><p>This post is too short to present all the numerous ways in which the control can be customized with the Java properties and methods. Let&#8217;s list some of the more interesting properties:</p><ul><li><b>Border</b> &#8211; specified the border frame around the button, which is responsible for its 3D appearance. It can be modified to anything from a simple colored borderline to a recurring icon-pattern, <a
href="http://java.sun.com/docs/books/tutorial/uiswing/components/border.html" rel="nofollow" target="_blank"> as shown here</a>. If set to [] then the button achieves a flat appearance, which can be useful for displaying click-able labels. For example, the blog hyperlink at the bottom of the FindJObj window is a simple button with no border, an HTML label and a callback that opens this blog webpage using the built-in <b><em>web</em></b> function:<br
/><center><div
id="attachment_198" class="wp-caption aligncenter" style="width: 160px"><img
src="http://undocumentedmatlab.com/blog/wp-content/uploads/2009/04/button_link-150x150.png" alt="Button appearing as a hyperlink label" title="button_link" width="150" height="150" class="size-thumbnail wp-image-198" /><p
class="wp-caption-text">Button appearing as a hyperlink label</p></div></center></p></li><li><b>Cursor</b> &#8211; this can be used to set a control-specific cursor. For example, in the hyperlink button above, the cursor was set to: java.awt.Cursor(java.awt.Cursor.HAND_CURSOR). In another post I&#8217;ll show how to set a custom cursor, like the following Matlab icon:<br
/><center><div
id="attachment_202" class="wp-caption aligncenter" style="width: 94px"><img
src="http://undocumentedmatlab.com/blog/wp-content/uploads/2009/04/cursor3.png" alt="Custom cursor" title="cursor3" width="84" height="44" class="size-full wp-image-202" /><p
class="wp-caption-text">Custom cursor</p></div></center></p></li><li><b>DisplayedMnemonicIndex</b> &#8211; (default=-1) indicates the character position within the text label where the Mnemonic (i.e, keyboard shortcut) should be displayed. Associated property <b>Mnemonic</b> (default=0) indicates the ASCII code of the mnemonic. In the following case, DisplayedMnemonicIndex=3 (remember that Java indices start at 0) and Mnemonic=73 (=&#8217;r'):<br
/><center><div
id="attachment_201" class="wp-caption aligncenter" style="width: 160px"><img
src="http://undocumentedmatlab.com/blog/wp-content/uploads/2009/04/button_mnemonic3.png" alt="Button With mnemonic" title="button_mnemonic3" width="60" height="20" class="size-full wp-image-201" /><p
class="wp-caption-text">Button With mnemonic</p></div></center></p></li><li><b>Margin, VerticalAlignment, HorizontalAlignment</b> &#8211; these properties enable setting the label contents with respect to its borders. For example:<br
/><center><div
id="attachment_207" class="wp-caption aligncenter" style="width: 160px"><img
src="http://undocumentedmatlab.com/blog/wp-content/uploads/2009/04/button_margin.png" alt="Top-left with 8-pixel top margin" title="button_margin" width="60" height="60" class="size-full wp-image-207" /><p
class="wp-caption-text">Top-left with 8-pixel top margin</p></div></center></p></li><li><b>Icon, DisabledIcon, DisabledSelectedIcon, PressedIcon, RolloverIcon, RolloverSelectedIcon, SelectedIcon </b> &#8211; these icons may be set to present a different appearance depending on component state. Associated property <b>IconTextGap</b> (default=4) determines the gap in pixels between the icon and the button text label. Associated properties <b>HorizontalTextPosition</b> and <b>VerticalTextPosition</b> specify the label text&#8217;s alignment relative to the label icon. These two properties accept the same SwingConstants values as HorizontalAlignment and VerticalAlignment above. For example, let&#8217;s display an icon to the right and upward of the text:<br
/><blockquote><pre><span style="color: #000000;">
myIcon = fullfile(matlabroot,</span><span style="color: #800080;">'/toolbox/matlab/icons/warning.gif'</span><span style="color: #000000;">);
jButton.setIcon(javax.swing.ImageIcon(myIcon));
jButton.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
jButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);</span>
</pre></blockquote><p><center><div
id="attachment_203" class="wp-caption aligncenter" style="width: 160px"><img
src="http://undocumentedmatlab.com/blog/wp-content/uploads/2009/04/button_icon3.png" alt="Button with text and icon" title="button_icon3" width="60" height="60" class="size-full wp-image-203" /><p
class="wp-caption-text">Button with text and icon</p></div></center></p></li><li><b>MultiClickThreshhold</b> &#8211; (default=0) sets the number of milliseconds between subsequent processed user mouse clicks on the button. Any clicks that occur within the specified number (e.g., fast double-clicks) will be considered by the component as only a single click.  The default value of 0 means that all clicks will be processed separately, which is often undesirable in GUI applications. Remember that the value is in milliseconds, not seconds.</li><li><b>FlyOverAppearance</b> &#8211; boolean flag (default=false); if set, the button appearance is changed to a flat (2D) appearance with a special 3D border effect displayed on mouse hover. This appearance is useful for toolbar buttons, and is an extension by Matlab&#8217;s button implementation (does not exist in the standard Swing class).</li></ul><p>There are quite a few other useful properties, methods (for example, jButton.<em>doClick()</em> to programmatically click a button) and even <a
target="_blank" href="http://undocumentedmatlab.com/blog/uicontrol-callbacks/">some 30 callbacks, detailed in a separate post</a>. The list above is by no way comprehensive &#8211; I hope it whet your appetites for exploration using FindJObj and UIINSPECT &#8211; it&#8217;s a fun ride and the GUI rewards are worth the effort!</p><p>Please let me know of any nice customizations in your Matlab applications. Leave a comment below or drop me an email.</p><p><pre> </pre>Related posts:<ol><li><a
href='http://undocumentedmatlab.com/blog/borderless-button-used-for-plot-properties/' rel='bookmark' title='Borderless button used for plot properties'>Borderless button used for plot properties</a> <small>A borderless button can be used to add unobtrusive functionality to plot axes...</small></li><li><a
href='http://undocumentedmatlab.com/blog/guide-customization/' rel='bookmark' title='GUIDE customization'>GUIDE customization</a> <small>Matlab's GUI Design Editor (GUIDE) has several interesting undocumented features. This post describes how to customize GUIDE rulers....</small></li><li><a
href='http://undocumentedmatlab.com/blog/uitable-customization-report/' rel='bookmark' title='Uitable customization report'>Uitable customization report</a> <small>In last week&#8217;s report about uitable sorting, I offered a report that I have written which covers uitable customization in detail. Several people have asked for more details about the...</small></li><li><a
href='http://undocumentedmatlab.com/blog/findjobj-gui-display-container-hierarchy/' rel='bookmark' title='FindJObj GUI &#8211; display container hierarchy'>FindJObj GUI &#8211; display container hierarchy</a> <small>The FindJObj utility can be used to present a GUI that displays a Matlab container's internal Java components, properties and callbacks....</small></li></ol></p><pre> </pre>]]></content:encoded> <wfw:commentRss>http://undocumentedmatlab.com/blog/button-customization/feed/</wfw:commentRss> <slash:comments>10</slash:comments> </item> </channel> </rss>

<!-- W3 Total Cache: Minify debug info:
Engine:             disk: basic
Theme:              b7666
Template:           tag
-->
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Served from: undocumentedmatlab.com @ 2012-05-21 20:34:48 -->

<!-- W3 Total Cache: Page cache debug info:
Engine:             disk: enhanced
Cache key:          blog/tag/uiinspect/feed/_index.xml_gzip
Caching:            enabled
Status:             not cached
Creation Time:      1.813s
Header info:
X-Pingback:         http://undocumentedmatlab.com/blog/xmlrpc.php
Set-Cookie:         wpgb_visit_last_php-default=1337657686; expires=Wed, 22-May-2013 03:34:46 GMT; path=/
Content-Type:       text/xml; charset=UTF-8
Last-Modified:      Tue, 22 May 2012 03:34:48 GMT
Vary:               Accept-Encoding, Cookie
Expires:            Tue, 22 May 2012 04:34:48 GMT
Pragma:             public
Cache-Control:      public, must-revalidate, proxy-revalidate
Etag:               d5aaff4d44c77cc0ffcbbb86c5941cdb
Content-Encoding:   gzip
-->
