This doesn&#39;t really fix the underlying problem highlighted by this bug report. The real problem is that UI_RETURN_OK is always returned, even on ESCKEY or RMB. The easiest &#39;fix&#39; is to remove the auto-activate for the text-field, even though that will ultimately disable a useful feature...<br>
<br><div class="gmail_quote">On Sat, Apr 19, 2008 at 11:44 PM, Campbell Barton &lt;<a href="mailto:ideasman42@gmail.com">ideasman42@gmail.com</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Revision: 14476<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a href="http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&amp;root=bf-blender&amp;revision=14476" target="_blank">http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&amp;root=bf-blender&amp;revision=14476</a><br>

Author: &nbsp; campbellbarton<br>
Date: &nbsp; &nbsp; 2008-04-19 13:44:09 +0200 (Sat, 19 Apr 2008)<br>
<br>
Log Message:<br>
-----------<br>
fix for [#7430] No way to back out of a PupStrInput() dialog<br>
<br>
Modified Paths:<br>
--------------<br>
 &nbsp; &nbsp;trunk/blender/source/blender/include/BIF_toolbox.h<br>
 &nbsp; &nbsp;trunk/blender/source/blender/src/toolbox.c<br>
<br>
Modified: trunk/blender/source/blender/include/BIF_toolbox.h<br>
===================================================================<br>
--- trunk/blender/source/blender/include/BIF_toolbox.h &nbsp;2008-04-19 11:26:51 UTC (rev 14475)<br>
+++ trunk/blender/source/blender/include/BIF_toolbox.h &nbsp;2008-04-19 11:44:09 UTC (rev 14476)<br>
@@ -47,7 +47,7 @@<br>
<br>
&nbsp;short button (short *var, short min, short max, char *str);<br>
&nbsp;short fbutton (float *var, float min, float max, float a1, float a2, char *str);<br>
-short sbutton (char *var, float min, float max, char *str); &nbsp; &nbsp;/* __NLA */<br>
+short sbutton (char *var, short min, short max, char *str); &nbsp; &nbsp;/* __NLA */<br>
<br>
&nbsp;int movetolayer_buts (unsigned int *lay, char *title);<br>
&nbsp;int movetolayer_short_buts (short *lay, char *title);<br>
<br>
Modified: trunk/blender/source/blender/src/toolbox.c<br>
===================================================================<br>
--- trunk/blender/source/blender/src/toolbox.c &nbsp;2008-04-19 11:26:51 UTC (rev 14475)<br>
+++ trunk/blender/source/blender/src/toolbox.c &nbsp;2008-04-19 11:44:09 UTC (rev 14476)<br>
@@ -291,13 +291,14 @@<br>
 &nbsp; &nbsp; &nbsp; &nbsp;return 0;<br>
&nbsp;}<br>
<br>
-short sbutton(char *var, float min, float max, char *str)<br>
+short sbutton(char *var, short min, short max, char *str)<br>
&nbsp;{<br>
 &nbsp; &nbsp; &nbsp; &nbsp;uiBlock *block;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;ListBase listb={0, 0};<br>
 &nbsp; &nbsp; &nbsp; &nbsp;short x1,y1;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;short mval[2], ret=0;<br>
-<br>
+ &nbsp; &nbsp; &nbsp; char *editvar = NULL; /* dont edit the original text, incase we cancel the popup */<br>
+<br>
 &nbsp; &nbsp; &nbsp; &nbsp;if(min&gt;max) min= max;<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;getmouseco_sc(mval);<br>
@@ -313,7 +314,10 @@<br>
 &nbsp; &nbsp; &nbsp; &nbsp;x1=mval[0]-250;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;y1=mval[1]-20;<br>
<br>
- &nbsp; &nbsp; &nbsp; uiDefButC(block, TEX, 32766, str, &nbsp; &nbsp; &nbsp; x1+5,y1+10,225,20, var,(float)min,(float)max, 0, 0, &quot;&quot;);<br>
+ &nbsp; &nbsp; &nbsp; editvar = MEM_callocN(max, &quot;sbutton&quot;);<br>
+ &nbsp; &nbsp; &nbsp; BLI_strncpy(editvar, var, max);<br>
+<br>
+ &nbsp; &nbsp; &nbsp; uiDefButC(block, TEX, 32766, str, &nbsp; &nbsp; &nbsp; x1+5,y1+10,225,20, editvar,(float)min,(float)max, 0, 0, &quot;&quot;);<br>
 &nbsp; &nbsp; &nbsp; &nbsp;uiDefBut(block, BUT, 32767, &quot;OK&quot;, &nbsp; &nbsp; &nbsp; x1+236,y1+10,25,20, NULL, 0, 0, 0, 0, &quot;&quot;);<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;uiBoundsBlock(block, 5);<br>
@@ -321,7 +325,12 @@<br>
 &nbsp; &nbsp; &nbsp; &nbsp;mainqenter_ext(BUT_ACTIVATE, 32766, 0); /* note, button id &#39;32766&#39; is asking for errors some day! */<br>
 &nbsp; &nbsp; &nbsp; &nbsp;ret= uiDoBlocks(&amp;listb, 0, 0);<br>
<br>
- &nbsp; &nbsp; &nbsp; if(ret==UI_RETURN_OK) return 1;<br>
+ &nbsp; &nbsp; &nbsp; if(ret==UI_RETURN_OK) {<br>
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BLI_strncpy(var, editvar, max);<br>
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MEM_freeN(editvar);<br>
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 1;<br>
+ &nbsp; &nbsp; &nbsp; }<br>
+ &nbsp; &nbsp; &nbsp; MEM_freeN(editvar);<br>
 &nbsp; &nbsp; &nbsp; &nbsp;return 0;<br>
<br>
&nbsp;}<br>
<br>
<br>
_______________________________________________<br>
Bf-blender-cvs mailing list<br>
<a href="mailto:Bf-blender-cvs@blender.org">Bf-blender-cvs@blender.org</a><br>
<a href="http://lists.blender.org/mailman/listinfo/bf-blender-cvs" target="_blank">http://lists.blender.org/mailman/listinfo/bf-blender-cvs</a><br>
</blockquote></div><br>