<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/159849</link>
    <title>MATLAB Central Newsreader - active change of textbox color?</title>
    <description>Feed for thread: active change of textbox color?</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2008 by The MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>The MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Sun, 25 Nov 2007 20:01:28 -0500</pubDate>
      <title>Re: active change of textbox color?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/159849#402989</link>
      <author>roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)</author>
      <description>In article &amp;lt;fib6nu$560$1@fred.mathworks.com&amp;gt;,&lt;br&gt;
Vihang Patil &amp;lt;vihang_patil@yahoo.com&amp;gt; wrote:&lt;br&gt;
&amp;gt;Hello I am trying to achieve the following;&lt;br&gt;
&lt;br&gt;
&amp;gt;1. I want the text box to change color only till the period&lt;br&gt;
&amp;gt; I have pressed the respective numeric button. If I release&lt;br&gt;
&amp;gt;the button it should turn "Red" again&lt;br&gt;
&amp;gt;2. If I press two or three buttons simultaneously they&lt;br&gt;
&amp;gt;should change color accordingly.&lt;br&gt;
&lt;br&gt;
I believe you will have to work at the Java level to achieve&lt;br&gt;
these goals. Matlab provides a KeyPressFcn callback but not&lt;br&gt;
a KeyReleaseFcn callback. Handling multiple buttons simultaneously&lt;br&gt;
will essentially require working at the keyboard scan code level.&lt;br&gt;
-- &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;"Beware of bugs in the above code; I have only proved it correct,&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;not tried it."                                    -- Donald Knuth&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Sun, 25 Nov 2007 07:03:26 -0500</pubDate>
      <title>active change of textbox color?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/159849#402943</link>
      <author>Vihang Patil</author>
      <description>Hello I am trying to achieve the following;&lt;br&gt;
I have made a figure window with 5 uicontrols of textbox type&lt;br&gt;
and assigned its background color property to "Red".&lt;br&gt;
Now I want the background color property of these textboxes&lt;br&gt;
to change depending upon the numeric value I enter. &lt;br&gt;
For example,&lt;br&gt;
If I press numeric 1 on my keyboard the First TextBox's&lt;br&gt;
background Color should change to "Green". If I press&lt;br&gt;
numeric 2 on my keyboard the second text box should turn&lt;br&gt;
"Green". and so on and so forth.&lt;br&gt;
I am able to achieve the basic requirement using the&lt;br&gt;
following code I have attached.&lt;br&gt;
But the problem is &lt;br&gt;
1. I want the text box to change color only till the period&lt;br&gt;
&amp;nbsp;I have pressed the respective numeric button. If I release&lt;br&gt;
the button it should turn "Red" again&lt;br&gt;
2. If I press two or three buttons simultaneously they&lt;br&gt;
should change color accordingly.&lt;br&gt;
&lt;br&gt;
My code currently does not change the color back to its&lt;br&gt;
original red color once I have stopped pressing the key and&lt;br&gt;
secondly I can only see one color change if I press two or&lt;br&gt;
more keys.&lt;br&gt;
Please guide&lt;br&gt;
&lt;br&gt;
Regards&lt;br&gt;
Vihang&lt;br&gt;
&lt;br&gt;
Attached Code......................&lt;br&gt;
&lt;br&gt;
function tempgui&lt;br&gt;
clear;close all, clc;&lt;br&gt;
handles.h = figure;&lt;br&gt;
handles.h1 = uicontrol('Style', 'text', 'String', '1',...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'Position', [20 150 50 50],'BackgroundColor','red');&lt;br&gt;
handles.h2 = uicontrol('Style', 'text', 'String', '2',...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'Position', [100 150 50 50],'BackgroundColor','red');&lt;br&gt;
handles.h3 = uicontrol('Style', 'text', 'String', '3',...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'Position', [180 150 50 50],'BackgroundColor','red');&lt;br&gt;
handles.h4 = uicontrol('Style', 'text', 'String', '4',...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'Position', [260 150 50 50],'BackgroundColor','red');&lt;br&gt;
handles.h5 = uicontrol('Style', 'text', 'String', '5',...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'Position', [340 150 50 50],'BackgroundColor','red');&lt;br&gt;
&lt;br&gt;
handles.tmr = timer('TimerFcn',&lt;br&gt;
{@TmrFCN,handles.h},'BusyMode','Queue',...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'ExecutionMode','FixedRate','Period',0.1);&lt;br&gt;
set(handles.h,'CloseRequestFcn',{@closefig,handles.h},'WindowStyle','Modal');&lt;br&gt;
&lt;br&gt;
guidata(handles.h,handles);&lt;br&gt;
start(handles.tmr);&lt;br&gt;
&lt;br&gt;
function TmrFCN(src,evnt,handles)&lt;br&gt;
handles = guidata(handles);&lt;br&gt;
val = get(handles.h,'CurrentCharacter');&lt;br&gt;
if val == '1'&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;set(handles.h1,'BackgroundColor','green');&lt;br&gt;
else&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;set(handles.h1,'BackgroundColor','red');&lt;br&gt;
end&lt;br&gt;
if val == '2'&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;set(handles.h2,'BackgroundColor','green');&lt;br&gt;
else&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;set(handles.h2,'BackgroundColor','red');&lt;br&gt;
end&lt;br&gt;
if val == '3'&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;set(handles.h3,'BackgroundColor','green');&lt;br&gt;
else&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;set(handles.h3,'BackgroundColor','red');&lt;br&gt;
end&lt;br&gt;
if val == '4'&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;set(handles.h4,'BackgroundColor','green');&lt;br&gt;
else&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;set(handles.h4,'BackgroundColor','red');&lt;br&gt;
end&lt;br&gt;
if val == '5'&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;set(handles.h5,'BackgroundColor','green');&lt;br&gt;
else&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;set(handles.h5,'BackgroundColor','red');&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
function closefig(src,evnt,handles)&lt;br&gt;
handles = guidata(handles);&lt;br&gt;
if strcmp&lt;br&gt;
(get(handles.tmr,'Running'),'on');stop(handles.tmr);end&lt;br&gt;
delete(handles.tmr);&lt;br&gt;
closereq;&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
</description>
    </item>
  </channel>
</rss>
