<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
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/"
> <channel><title>Comments on: Detecting window focus events</title> <atom:link href="http://undocumentedmatlab.com/blog/detecting-window-focus-events/feed/" rel="self" type="application/rss+xml" /><link>http://undocumentedmatlab.com/blog/detecting-window-focus-events/</link> <description>Charting Matlab's unsupported hidden underbelly</description> <lastBuildDate>Fri, 18 May 2012 13:56:51 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.1.1</generator> <item><title>By: Malcolm Lidierth</title><link>http://undocumentedmatlab.com/blog/detecting-window-focus-events/#comment-44077</link> <dc:creator>Malcolm Lidierth</dc:creator> <pubDate>Fri, 20 May 2011 11:34:43 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=584#comment-44077</guid> <description>JText**** text edits are thread-safe: they are always run on the EDT by the Swing component&#039;s own code. A drawnow() from MATLAB might help if the screen is not updating.</description> <content:encoded><![CDATA[<p>JText**** text edits are thread-safe: they are always run on the EDT by the Swing component&#8217;s own code. A drawnow() from MATLAB might help if the screen is not updating.</p> ]]></content:encoded> </item> <item><title>By: Yair Altman</title><link>http://undocumentedmatlab.com/blog/detecting-window-focus-events/#comment-39610</link> <dc:creator>Yair Altman</dc:creator> <pubDate>Mon, 11 Apr 2011 12:46:27 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=584#comment-39610</guid> <description>@Jamil - unfortunately, the current website design does not enable comment modification/deletion...</description> <content:encoded><![CDATA[<p>@Jamil &#8211; unfortunately, the current website design does not enable comment modification/deletion&#8230;</p> ]]></content:encoded> </item> <item><title>By: Jamil Onaran</title><link>http://undocumentedmatlab.com/blog/detecting-window-focus-events/#comment-39602</link> <dc:creator>Jamil Onaran</dc:creator> <pubDate>Mon, 11 Apr 2011 11:41:35 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=584#comment-39602</guid> <description>There should be a way to delete modify these comment, is there a way that I don&#039;t know?</description> <content:encoded><![CDATA[<p>There should be a way to delete modify these comment, is there a way that I don&#8217;t know?</p> ]]></content:encoded> </item> <item><title>By: Jamil Onaran</title><link>http://undocumentedmatlab.com/blog/detecting-window-focus-events/#comment-39600</link> <dc:creator>Jamil Onaran</dc:creator> <pubDate>Mon, 11 Apr 2011 11:37:04 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=584#comment-39600</guid> <description>Hi Donn,
I got it, but I just demonstrated what createuimode.m does to disable the callback of axis component. After calling handle function for &lt;code&gt;axisComponenent&lt;/code&gt;, we can not assign any callback to &lt;code&gt;AxisCompnent&lt;/code&gt;. But your method works perfect and solved my problem. I&#039;m using the following code to get the &lt;code&gt;axisComponent&lt;/code&gt;.
&lt;pre lang=&quot;matlab&quot;&gt;
mde = com.mathworks.mde.desk.MLDesktop.getInstance;
figName = get(hObject,&#039;name&#039;);
if strcmpi(get(hObject,&#039;number&#039;),&#039;on&#039;)
figName = regexprep([&#039;Figure &#039; num2str(hObject) &#039;: &#039; figName],&#039;: $&#039;,&#039;&#039;);
end
jFig = []; iTry = 10;
while isempty(jFig) &amp;&amp; iTry
jFig = mde.getClient(figName);
iTry = iTry-1;
pause(0.1);
end
axisComponent = jFig.getComponent(0).getComponent(0).getComponent(1);
axisComponent = handle(axisComponent, &#039;CallbackProperties&#039;);
&lt;/pre&gt;
This is an alternative method to get the axis component, but we can not obtain JavaFrame object from this code. I wish Matlab won&#039;t stop supporting the javaframe.
Do you have other work arounds if  they do so?</description> <content:encoded><![CDATA[<p>Hi Donn,<br
/> I got it, but I just demonstrated what createuimode.m does to disable the callback of axis component. After calling handle function for <code>axisComponenent</code>, we can not assign any callback to <code>AxisCompnent</code>. But your method works perfect and solved my problem. I&#8217;m using the following code to get the <code>axisComponent</code>.</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">mde = com.<span style="">mathworks</span>.<span style="">mde</span>.<span style="">desk</span>.<span style="">MLDesktop</span>.<span style="">getInstance</span>;
figName = <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>hObject,<span style="color:#A020F0;">'name'</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">if</span> <span style="color: #0000FF;">strcmpi</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>hObject,<span style="color:#A020F0;">'number'</span><span style="color: #080;">&#41;</span>,<span style="color:#A020F0;">'on'</span><span style="color: #080;">&#41;</span>
    figName = regexprep<span style="color: #080;">&#40;</span><span style="color: #080;">&#91;</span><span style="color:#A020F0;">'Figure '</span> <span style="color: #0000FF;">num2str</span><span style="color: #080;">&#40;</span>hObject<span style="color: #080;">&#41;</span> <span style="color:#A020F0;">': '</span> figName<span style="color: #080;">&#93;</span>,<span style="color:#A020F0;">': $'</span>,<span style="color:#A020F0;">''</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">end</span>
jFig = <span style="color: #080;">&#91;</span><span style="color: #080;">&#93;</span>; iTry = <span style="color: #33f;">10</span>;
<span style="color: #0000FF;">while</span> <span style="color: #0000FF;">isempty</span><span style="color: #080;">&#40;</span>jFig<span style="color: #080;">&#41;</span> <span style="color: #F0F;">&amp;</span>amp;<span style="color: #F0F;">&amp;</span>amp; iTry
    jFig = mde.<span style="">getClient</span><span style="color: #080;">&#40;</span>figName<span style="color: #080;">&#41;</span>;
    iTry = iTry-<span style="color: #33f;">1</span>;
    <span style="color: #0000FF;">pause</span><span style="color: #080;">&#40;</span><span style="color: #33f;">0.1</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">end</span>
axisComponent = jFig.<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;">0</span><span style="color: #080;">&#41;</span>.<span style="">getComponent</span><span style="color: #080;">&#40;</span><span style="color: #33f;">1</span><span style="color: #080;">&#41;</span>;
axisComponent = handle<span style="color: #080;">&#40;</span>axisComponent, <span style="color:#A020F0;">'CallbackProperties'</span><span style="color: #080;">&#41;</span>;</pre></div></div><p>This is an alternative method to get the axis component, but we can not obtain JavaFrame object from this code. I wish Matlab won&#8217;t stop supporting the javaframe.<br
/> Do you have other work arounds if  they do so?</p> ]]></content:encoded> </item> <item><title>By: Donn Shull</title><link>http://undocumentedmatlab.com/blog/detecting-window-focus-events/#comment-38983</link> <dc:creator>Donn Shull</dc:creator> <pubDate>Wed, 06 Apr 2011 15:16:50 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=584#comment-38983</guid> <description>@Jamil – To summarize: To have callback properties the UDD peer must be created in the javahandle_withcallbacks package. In your code above you should use:&lt;pre lang=&quot;matlab&quot;&gt;
Frame  = get(hFig,&#039;JavaFrame&#039;, &#039;CallbackProperties&#039;);
&lt;/pre&gt;Then you will not generate errors. As Yair has explained hgload will create the UDD peer in the javahandle package which does not have callback properties. If you wish to use hgsave and hgload then you should design your code using &lt;code&gt;handle.listener&lt;/code&gt; to process events. You need to take care to use the proper event names and provide persistent storage for your listener objects.Donn</description> <content:encoded><![CDATA[<p>@Jamil – To summarize: To have callback properties the UDD peer must be created in the javahandle_withcallbacks package. In your code above you should use:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">Frame  = <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>hFig,<span style="color:#A020F0;">'JavaFrame'</span>, <span style="color:#A020F0;">'CallbackProperties'</span><span style="color: #080;">&#41;</span>;</pre></div></div><p>Then you will not generate errors. As Yair has explained hgload will create the UDD peer in the javahandle package which does not have callback properties. If you wish to use hgsave and hgload then you should design your code using <code>handle.listener</code> to process events. You need to take care to use the proper event names and provide persistent storage for your listener objects.</p><p>Donn</p> ]]></content:encoded> </item> <item><title>By: Jamil Onaran</title><link>http://undocumentedmatlab.com/blog/detecting-window-focus-events/#comment-38963</link> <dc:creator>Jamil Onaran</dc:creator> <pubDate>Wed, 06 Apr 2011 07:58:21 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=584#comment-38963</guid> <description>Hi again,
Actually this is not a visibility issue.
I have a test code below, using handles on AxisComponent will cause this error if we try to install a a callback.
&lt;pre lang=&quot;matlab&quot;&gt;
%% Create a new figure
close all
hFig = figure;
%% Run this to generate an error
Frame  = get(hFig,&#039;JavaFrame&#039;);
hFrame = handle(Frame);
hAxisComponent = handle(hFrame.getAxisComponent);
%% Get java frame and install a callback
Frame  = get(hFig,&#039;JavaFrame&#039;);
AxisComponent = Frame.getAxisComponent;
set(AxisComponent,&#039;MouseMovedCallback&#039;,@(a,b) disp(&#039;MMC&#039;))
&lt;/pre&gt;</description> <content:encoded><![CDATA[<p>Hi again,<br
/> Actually this is not a visibility issue.<br
/> I have a test code below, using handles on AxisComponent will cause this error if we try to install a a callback.</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">%% Create a new figure</span>
<span style="color: #0000FF;">close</span> <span style="color: #0000FF;">all</span>
hFig = <span style="color: #0000FF;">figure</span>;
<span style="color: #228B22;">%% Run this to generate an error</span>
Frame  = <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>;
hFrame = handle<span style="color: #080;">&#40;</span>Frame<span style="color: #080;">&#41;</span>;
hAxisComponent = handle<span style="color: #080;">&#40;</span>hFrame.<span style="">getAxisComponent</span><span style="color: #080;">&#41;</span>;
<span style="color: #228B22;">%% Get java frame and install a callback</span>
Frame  = <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>;
AxisComponent = Frame.<span style="">getAxisComponent</span>;
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>AxisComponent,<span style="color:#A020F0;">'MouseMovedCallback'</span>,@<span style="color: #080;">&#40;</span>a,b<span style="color: #080;">&#41;</span> <span style="color: #0000FF;">disp</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'MMC'</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span></pre></div></div>]]></content:encoded> </item> <item><title>By: Jamil Onaran</title><link>http://undocumentedmatlab.com/blog/detecting-window-focus-events/#comment-38951</link> <dc:creator>Jamil Onaran</dc:creator> <pubDate>Wed, 06 Apr 2011 05:56:27 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=584#comment-38951</guid> <description>Thanks,
I figured it out.
toolbox\matlab\uitools\@uitools\@uimode\createuimode.m file cuases this problem, here is the corresponding code. The callbacks are usable until this line.
&lt;pre lang=&quot;matlab&quot;&gt;
hAxisComponent = handle(hFrame.getAxisComponent);
&lt;/pre&gt;
If you use get function for the axis component before this line or set the figure visible, the callbacks would be working. I don&#039;t exactly know what handle is doing on invisible figures.</description> <content:encoded><![CDATA[<p>Thanks,<br
/> I figured it out.<br
/> toolbox\matlab\uitools\@uitools\@uimode\createuimode.m file cuases this problem, here is the corresponding code. The callbacks are usable until this line.</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">    hAxisComponent = handle<span style="color: #080;">&#40;</span>hFrame.<span style="">getAxisComponent</span><span style="color: #080;">&#41;</span>;</pre></div></div><p> If you use get function for the axis component before this line or set the figure visible, the callbacks would be working. I don&#8217;t exactly know what handle is doing on invisible figures.</p> ]]></content:encoded> </item> <item><title>By: Donn Shull</title><link>http://undocumentedmatlab.com/blog/detecting-window-focus-events/#comment-38934</link> <dc:creator>Donn Shull</dc:creator> <pubDate>Wed, 06 Apr 2011 02:46:33 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=584#comment-38934</guid> <description>@Jamil – Note that when using handle.listener you need to use the event name which in your case is &#039;MouseMoved&#039; rather than the callback property name which is &#039;MouseMovedCallback&#039;.&lt;pre lang=&quot;matlab&quot;&gt;
hgsave test
hgload test
jFig1 = get(handle(gcf), &#039;JavaFrame&#039;);
jAxis1 = jFig1.getAxisComponent;
l = handle.listener(handle(jAxis1),&#039;MouseMoved&#039;,@(a,b) disp(&#039;ab&#039;))
&lt;/pre&gt;</description> <content:encoded><![CDATA[<p>@Jamil – Note that when using handle.listener you need to use the event name which in your case is &#8216;MouseMoved&#8217; rather than the callback property name which is &#8216;MouseMovedCallback&#8217;.</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">hgsave test
hgload test
&nbsp;
jFig1 = <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>handle<span style="color: #080;">&#40;</span><span style="color: #0000FF;">gcf</span><span style="color: #080;">&#41;</span>, <span style="color:#A020F0;">'JavaFrame'</span><span style="color: #080;">&#41;</span>;
jAxis1 = jFig1.<span style="">getAxisComponent</span>;
l = <span style="color: #0000FF;">handle.<span style="">listener</span></span><span style="color: #080;">&#40;</span>handle<span style="color: #080;">&#40;</span>jAxis1<span style="color: #080;">&#41;</span>,<span style="color:#A020F0;">'MouseMoved'</span>,@<span style="color: #080;">&#40;</span>a,b<span style="color: #080;">&#41;</span> <span style="color: #0000FF;">disp</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'ab'</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span></pre></div></div>]]></content:encoded> </item> <item><title>By: Yair Altman</title><link>http://undocumentedmatlab.com/blog/detecting-window-focus-events/#comment-38917</link> <dc:creator>Yair Altman</dc:creator> <pubDate>Tue, 05 Apr 2011 22:01:39 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=584#comment-38917</guid> <description>@Jamil - this may be the same issue as Kesh mentioned in comments above - please see my answer &lt;a href=&quot;http://undocumentedmatlab.com/blog/detecting-window-focus-events/#comment-14472&quot; rel=&quot;nofollow&quot;&gt;there&lt;/a&gt;. In short, Java callbacks don&#039;t work as advertised for &lt;b&gt;&lt;i&gt;hgload&lt;/i&gt;&lt;/b&gt;ed figures - only for figures created in runtime. This appears to be due to an internal Matlab bug, but I would not hold my breath for it to be fixed...Try using &lt;a href=&quot;http://undocumentedmatlab.com/blog/detecting-window-focus-events/#comment-14684&quot; rel=&quot;nofollow&quot;&gt;Donn&#039;s suggested workaround&lt;/a&gt; of using UDD&#039;s &lt;b&gt;&lt;i&gt;handle.listener&lt;/i&gt;&lt;/b&gt; function, which are explained in detail in &lt;a href=&quot;http://undocumentedmatlab.com/blog/udd-events-and-listeners/&quot; rel=&quot;nofollow&quot;&gt;this article&lt;/a&gt;.</description> <content:encoded><![CDATA[<p>@Jamil &#8211; this may be the same issue as Kesh mentioned in comments above &#8211; please see my answer <a
href="http://undocumentedmatlab.com/blog/detecting-window-focus-events/#comment-14472" rel="nofollow">there</a>. In short, Java callbacks don&#8217;t work as advertised for <b><i>hgload</i></b>ed figures &#8211; only for figures created in runtime. This appears to be due to an internal Matlab bug, but I would not hold my breath for it to be fixed&#8230;</p><p>Try using <a
href="http://undocumentedmatlab.com/blog/detecting-window-focus-events/#comment-14684" rel="nofollow">Donn&#8217;s suggested workaround</a> of using UDD&#8217;s <b><i>handle.listener</i></b> function, which are explained in detail in <a
href="http://undocumentedmatlab.com/blog/udd-events-and-listeners/" rel="nofollow">this article</a>.</p> ]]></content:encoded> </item> <item><title>By: Jamil Onaran</title><link>http://undocumentedmatlab.com/blog/detecting-window-focus-events/#comment-38909</link> <dc:creator>Jamil Onaran</dc:creator> <pubDate>Tue, 05 Apr 2011 20:13:59 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=584#comment-38909</guid> <description>Hi Donn
The below code did not work for the loaded figure, unlike the FocusGained callback. Is there another work  around for this problem.
&lt;pre lang=&quot;matlab&quot;&gt;
hgsave test
hgload test
jFig1 = get(handle(gcf), &#039;JavaFrame&#039;);
jAxis1 = jFig1.getAxisComponent;
l = handle.listener(handle(jAxis1),&#039;MouseMovedCallback&#039;,@(a,b) disp(&#039;ab&#039;))
&lt;/pre&gt;
Thanks</description> <content:encoded><![CDATA[<p>Hi Donn<br
/> The below code did not work for the loaded figure, unlike the FocusGained callback. Is there another work  around for this problem.</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">hgsave test
hgload test
&nbsp;
jFig1 = <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>handle<span style="color: #080;">&#40;</span><span style="color: #0000FF;">gcf</span><span style="color: #080;">&#41;</span>, <span style="color:#A020F0;">'JavaFrame'</span><span style="color: #080;">&#41;</span>;
jAxis1 = jFig1.<span style="">getAxisComponent</span>;
l = <span style="color: #0000FF;">handle.<span style="">listener</span></span><span style="color: #080;">&#40;</span>handle<span style="color: #080;">&#40;</span>jAxis1<span style="color: #080;">&#41;</span>,<span style="color:#A020F0;">'MouseMovedCallback'</span>,@<span style="color: #080;">&#40;</span>a,b<span style="color: #080;">&#41;</span> <span style="color: #0000FF;">disp</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'ab'</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span></pre></div></div><p>Thanks</p> ]]></content:encoded> </item> </channel> </rss>

<!-- W3 Total Cache: Minify debug info:
Engine:             disk: basic
Theme:              b7666
Template:           single
-->
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Served from: undocumentedmatlab.com @ 2012-05-18 22:38:56 -->

<!-- W3 Total Cache: Page cache debug info:
Engine:             disk: enhanced
Cache key:          blog/detecting-window-focus-events/feed/_index.xml_gzip
Caching:            enabled
Status:             not cached
Creation Time:      0.534s
Header info:
X-Pingback:         http://undocumentedmatlab.com/blog/xmlrpc.php
Set-Cookie:         wpgb_visit_last_php-default=1337405936; expires=Sun, 19-May-2013 05:38:56 GMT; path=/
Link:               <http://undocumentedmatlab.com/?p=584>; rel=shortlink
Content-Type:       text/xml; charset=UTF-8
Last-Modified:      Sat, 19 May 2012 05:38:56 GMT
Vary:               Accept-Encoding, Cookie
Expires:            Sat, 19 May 2012 06:38:56 GMT
Pragma:             public
Cache-Control:      public, must-revalidate, proxy-revalidate
Etag:               fb791ddc1d0a2e31869202384865e45a
Content-Encoding:   gzip
-->
