<?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: Uicontrol callbacks	</title>
	<atom:link href="https://undocumentedmatlab.com/articles/uicontrol-callbacks/feed" rel="self" type="application/rss+xml" />
	<link>https://undocumentedmatlab.com/articles/uicontrol-callbacks?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=uicontrol-callbacks</link>
	<description>Professional Matlab consulting, development and training</description>
	<lastBuildDate>Sun, 30 Jan 2022 08:54:07 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.2</generator>
	<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/uicontrol-callbacks#comment-513321</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Sun, 30 Jan 2022 08:54:07 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=223#comment-513321</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/uicontrol-callbacks#comment-513314&quot;&gt;maiky76&lt;/a&gt;.

Answer posted here: http://undocumentedmatlab.com/articles/gui-automation-robot#comment-513320]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/uicontrol-callbacks#comment-513314">maiky76</a>.</p>
<p>Answer posted here: <a href="http://undocumentedmatlab.com/articles/gui-automation-robot#comment-513320" rel="ugc">http://undocumentedmatlab.com/articles/gui-automation-robot#comment-513320</a></p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: maiky76		</title>
		<link>https://undocumentedmatlab.com/articles/uicontrol-callbacks#comment-513314</link>

		<dc:creator><![CDATA[maiky76]]></dc:creator>
		<pubDate>Sat, 29 Jan 2022 04:03:51 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=223#comment-513314</guid>

					<description><![CDATA[Thanks for this great post.
It’s got me up and running in no time.
I have to make an Octave version of it and I am really struggling.

Here is the code that behave as I’d like it to:
Open external program, return to Matlab/Octave script, Matlab/Octave makes some keyboard inputs closes the program, then back to Matlab/Octave to finish the remaining commands of the script

&lt;pre lang=&quot;matlab&quot;&gt;
import java.awt.*;
import java.awt.event.*;

system(&#039;&quot;calc.exe&quot;&#038;&#039;);

R2D2 = Robot;
R2D2.delay(100) 
R2D2.keyPress(KeyEvent.VK_8)
R2D2.keyRelease(KeyEvent.VK_8)
R2D2.delay(1000)  
R2D2.keyPress(KeyEvent.VK_ALT)
R2D2.keyPress(KeyEvent.VK_F4)
R2D2.keyRelease(KeyEvent.VK_ALT)
R2D2.keyRelease(KeyEvent.VK_F4)
&lt;/pre&gt;

with Octave I am stuck here

&lt;pre lang=&quot;matlab&quot;&gt;
% There is no import function 
% OBJ = java_set/get (OBJ, NAME, VAL)
% jobj = javaObject (classname, arg1, …)
% Ret = javaMethod (methodname, obj, arg1, …)

system(&quot;calc.exe&quot;, false, &quot;async&quot;); 

R2D2 = javaObject(&quot;java.awt.Robot&quot;); % OK
methods (R2D2)

R2D2.delay(5000); % OK
% robot.keyPress (java.awt.event.KeyEvent.VK_SHIFT); KO
&lt;/pre&gt;

&lt;pre lang=&quot;matlab&quot;&gt;
R2D2 = javaObject(“java.awt.Robot”);
methods (R2D2)
&lt;/pre&gt;
shows that keyPress is a valid method so something along the lines of
&lt;pre lang=&quot;matlab&quot;&gt;javaMethod (‘keyPress’, R2D2, , ...)&lt;/pre&gt;
and
&lt;pre lang=&quot;matlab&quot;&gt;R2D2.keyPress (, …`)&lt;/pre&gt;
should work.
The problem is that as soon as the method call doesn’t painfully exactly conforms to the method “signature”, Octave is only able to signal that fact using the one error message it has there and that’s the NoSuchMethodException - even though the method DOES exist

The reason why I am interested can we found here: &lt;a href=&quot;https://www.diyaudio.com/community/threads/acoustic-horn-design-the-easy-way-ath4.338806/page-459#post-6916828&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;Acoustic Horn Design – The Easy Way (Ath4) &#124; Page 459 &#124; diyAudio)&lt;/a&gt;
We are trying to perform some optimization on the design of an DIY acoustic waveguide.
Any help would be much appreciated!

PS checkClass.m crashes Matlab 2018b]]></description>
			<content:encoded><![CDATA[<p>Thanks for this great post.<br />
It’s got me up and running in no time.<br />
I have to make an Octave version of it and I am really struggling.</p>
<p>Here is the code that behave as I’d like it to:<br />
Open external program, return to Matlab/Octave script, Matlab/Octave makes some keyboard inputs closes the program, then back to Matlab/Octave to finish the remaining commands of the script</p>
<pre lang="matlab">
import java.awt.*;
import java.awt.event.*;

system('"calc.exe"&amp;');

R2D2 = Robot;
R2D2.delay(100) 
R2D2.keyPress(KeyEvent.VK_8)
R2D2.keyRelease(KeyEvent.VK_8)
R2D2.delay(1000)  
R2D2.keyPress(KeyEvent.VK_ALT)
R2D2.keyPress(KeyEvent.VK_F4)
R2D2.keyRelease(KeyEvent.VK_ALT)
R2D2.keyRelease(KeyEvent.VK_F4)
</pre>
<p>with Octave I am stuck here</p>
<pre lang="matlab">
% There is no import function 
% OBJ = java_set/get (OBJ, NAME, VAL)
% jobj = javaObject (classname, arg1, …)
% Ret = javaMethod (methodname, obj, arg1, …)

system("calc.exe", false, "async"); 

R2D2 = javaObject("java.awt.Robot"); % OK
methods (R2D2)

R2D2.delay(5000); % OK
% robot.keyPress (java.awt.event.KeyEvent.VK_SHIFT); KO
</pre>
<pre lang="matlab">
R2D2 = javaObject(“java.awt.Robot”);
methods (R2D2)
</pre>
<p>shows that keyPress is a valid method so something along the lines of</p>
<pre lang="matlab">javaMethod (‘keyPress’, R2D2, , ...)</pre>
<p>and</p>
<pre lang="matlab">R2D2.keyPress (, …`)</pre>
<p>should work.<br />
The problem is that as soon as the method call doesn’t painfully exactly conforms to the method “signature”, Octave is only able to signal that fact using the one error message it has there and that’s the NoSuchMethodException &#8211; even though the method DOES exist</p>
<p>The reason why I am interested can we found here: <a href="https://www.diyaudio.com/community/threads/acoustic-horn-design-the-easy-way-ath4.338806/page-459#post-6916828" target="_blank" rel="nofollow">Acoustic Horn Design – The Easy Way (Ath4) | Page 459 | diyAudio)</a><br />
We are trying to perform some optimization on the design of an DIY acoustic waveguide.<br />
Any help would be much appreciated!</p>
<p>PS checkClass.m crashes Matlab 2018b</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/uicontrol-callbacks#comment-420349</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Tue, 13 Mar 2018 08:46:52 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=223#comment-420349</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/uicontrol-callbacks#comment-420343&quot;&gt;Nipurn Jain&lt;/a&gt;.

see answer &lt;a href=&quot;http://undocumentedmatlab.com/blog/customizing-editboxes#comment-420348&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/uicontrol-callbacks#comment-420343">Nipurn Jain</a>.</p>
<p>see answer <a href="http://undocumentedmatlab.com/blog/customizing-editboxes#comment-420348" target="_blank" rel="nofollow">here</a></p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Nipurn Jain		</title>
		<link>https://undocumentedmatlab.com/articles/uicontrol-callbacks#comment-420344</link>

		<dc:creator><![CDATA[Nipurn Jain]]></dc:creator>
		<pubDate>Tue, 13 Mar 2018 06:58:22 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=223#comment-420344</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/uicontrol-callbacks#comment-420343&quot;&gt;Nipurn Jain&lt;/a&gt;.

I have an application where there are several buttons that apply a specific function to the data. The user can also enter values in the edit box. However if the cursor is positioned in the edit box and a button is pressed the new function will appear at the end of the edit box and I need that this appear at cursor position how to do this?]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/uicontrol-callbacks#comment-420343">Nipurn Jain</a>.</p>
<p>I have an application where there are several buttons that apply a specific function to the data. The user can also enter values in the edit box. However if the cursor is positioned in the edit box and a button is pressed the new function will appear at the end of the edit box and I need that this appear at cursor position how to do this?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Nipurn Jain		</title>
		<link>https://undocumentedmatlab.com/articles/uicontrol-callbacks#comment-420343</link>

		<dc:creator><![CDATA[Nipurn Jain]]></dc:creator>
		<pubDate>Tue, 13 Mar 2018 06:57:48 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=223#comment-420343</guid>

					<description><![CDATA[How to determine cursor position in &#039;edit&#039; uicontrol?

I have an application where there are several buttons that apply a specific function to the data. The user can also enter values in the edit box. However if the cursor is positioned in the edit box and a button is pressed the new function will appear at the end of the edit box and I need that this appear at cursor position how to do this?
Is it possible by using javaframe available on matlab?]]></description>
			<content:encoded><![CDATA[<p>How to determine cursor position in &#8216;edit&#8217; uicontrol?</p>
<p>I have an application where there are several buttons that apply a specific function to the data. The user can also enter values in the edit box. However if the cursor is positioned in the edit box and a button is pressed the new function will appear at the end of the edit box and I need that this appear at cursor position how to do this?<br />
Is it possible by using javaframe available on matlab?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/uicontrol-callbacks#comment-407492</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Sun, 28 May 2017 09:23:35 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=223#comment-407492</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/uicontrol-callbacks#comment-407407&quot;&gt;Noah&lt;/a&gt;.

@Noah - yes, this is indeed possible but the Java class would need to be written in a specific way to enable Matlab callbacks for the Java events. Contact me offline (altmany at gmail) for assistance.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/uicontrol-callbacks#comment-407407">Noah</a>.</p>
<p>@Noah &#8211; yes, this is indeed possible but the Java class would need to be written in a specific way to enable Matlab callbacks for the Java events. Contact me offline (altmany at gmail) for assistance.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Noah		</title>
		<link>https://undocumentedmatlab.com/articles/uicontrol-callbacks#comment-407407</link>

		<dc:creator><![CDATA[Noah]]></dc:creator>
		<pubDate>Fri, 26 May 2017 20:22:05 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=223#comment-407407</guid>

					<description><![CDATA[Yair,

Is there a generic way to pass a Matlab method to Java (that Java can execute) without having to use JFrame?
e.g.
&lt;pre lang=&quot;matlab&quot;&gt;
classdef HelloWorld
   method
      function this = HelloWorld()
        %Pass HelloWorld.jar main entry point HellowWorld callback method
        a = HelloWorld;
        %Notional (here main is any HelloWorld class method, not limited to a JFrame callback)
        set(a,&#039;main&#039;,{@this.callback,parm1,parm2,...})
      end
   end
   method
      function callback(parm1, parm2,...)
         ...
      end
   end
end
&lt;/pre&gt;
If this is do-able I&#039;d be willing to donate numerous coffee&#039;s :)

Thanks in advance,
Noah]]></description>
			<content:encoded><![CDATA[<p>Yair,</p>
<p>Is there a generic way to pass a Matlab method to Java (that Java can execute) without having to use JFrame?<br />
e.g.</p>
<pre lang="matlab">
classdef HelloWorld
   method
      function this = HelloWorld()
        %Pass HelloWorld.jar main entry point HellowWorld callback method
        a = HelloWorld;
        %Notional (here main is any HelloWorld class method, not limited to a JFrame callback)
        set(a,'main',{@this.callback,parm1,parm2,...})
      end
   end
   method
      function callback(parm1, parm2,...)
         ...
      end
   end
end
</pre>
<p>If this is do-able I&#8217;d be willing to donate numerous coffee&#8217;s 🙂</p>
<p>Thanks in advance,<br />
Noah</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/uicontrol-callbacks#comment-399147</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Sat, 28 Jan 2017 17:23:51 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=223#comment-399147</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/uicontrol-callbacks#comment-399109&quot;&gt;Efraim&lt;/a&gt;.

There is no specific Java callback that does exactly what you want as far as I know. You can possibly achieve this functionality by programmatic logic using a combination of the existing callbacks.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/uicontrol-callbacks#comment-399109">Efraim</a>.</p>
<p>There is no specific Java callback that does exactly what you want as far as I know. You can possibly achieve this functionality by programmatic logic using a combination of the existing callbacks.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Efraim		</title>
		<link>https://undocumentedmatlab.com/articles/uicontrol-callbacks#comment-399109</link>

		<dc:creator><![CDATA[Efraim]]></dc:creator>
		<pubDate>Fri, 27 Jan 2017 13:29:52 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=223#comment-399109</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/uicontrol-callbacks#comment-399102&quot;&gt;Efraim&lt;/a&gt;.

Hi Yair,
Thanks for your suggestion. I tried but it didn&#039;t work the way I want it.
Here&#039;s an example.
&lt;pre lang=&quot;matlab&quot;&gt;
f=figure;
u=uicontrol(&#039;style&#039;,&#039;popup&#039;,&#039;string&#039;,{&#039;one&#039;,&#039;two&#039;,&#039;three&#039;,&#039;four&#039;});
jo=findjobj(u);
jbh=handle(jo,&#039;CallbackProperties&#039;);
set(jbh,&#039;ActionPerformedCallback&#039;,&#039;disp(123);&#039;)
&lt;/pre&gt;

If I&#039;d type &#039;t&#039; it would select &#039;two&#039; (and show 123 in the command line). But I don&#039;t want it to show 123 just yet, only if I press enter, or if I had selected one of the items using the mouse.
Hope it&#039;s more clear!]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/uicontrol-callbacks#comment-399102">Efraim</a>.</p>
<p>Hi Yair,<br />
Thanks for your suggestion. I tried but it didn&#8217;t work the way I want it.<br />
Here&#8217;s an example.</p>
<pre lang="matlab">
f=figure;
u=uicontrol('style','popup','string',{'one','two','three','four'});
jo=findjobj(u);
jbh=handle(jo,'CallbackProperties');
set(jbh,'ActionPerformedCallback','disp(123);')
</pre>
<p>If I&#8217;d type &#8216;t&#8217; it would select &#8216;two&#8217; (and show 123 in the command line). But I don&#8217;t want it to show 123 just yet, only if I press enter, or if I had selected one of the items using the mouse.<br />
Hope it&#8217;s more clear!</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/uicontrol-callbacks#comment-399103</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Fri, 27 Jan 2017 12:50:26 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=223#comment-399103</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/uicontrol-callbacks#comment-399102&quot;&gt;Efraim&lt;/a&gt;.

Use the &lt;b&gt;ActionPerformedCallback&lt;/b&gt;]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/uicontrol-callbacks#comment-399102">Efraim</a>.</p>
<p>Use the <b>ActionPerformedCallback</b></p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
