diff options
author | Campbell Barton <ideasman42@gmail.com> | 2008-04-19 15:44:09 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2008-04-19 15:44:09 +0400 |
commit | c870ed12368d7e67dcf188d7d11d5977eb1cef6f (patch) | |
tree | df45a0795105a14cccb7536c3b09a41516aa94b6 /source | |
parent | 8a888dbdc794668d3043b075ae6d7a5d7d0a2c0e (diff) |
fix for [#7430] No way to back out of a PupStrInput() dialog
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/include/BIF_toolbox.h | 2 | ||||
-rw-r--r-- | source/blender/src/toolbox.c | 17 |
2 files changed, 14 insertions, 5 deletions
diff --git a/source/blender/include/BIF_toolbox.h b/source/blender/include/BIF_toolbox.h index 2a0c76cc437..dc2d5a89e9d 100644 --- a/source/blender/include/BIF_toolbox.h +++ b/source/blender/include/BIF_toolbox.h @@ -47,7 +47,7 @@ int okee (char *fmt, ...); short button (short *var, short min, short max, char *str); short fbutton (float *var, float min, float max, float a1, float a2, char *str); -short sbutton (char *var, float min, float max, char *str); /* __NLA */ +short sbutton (char *var, short min, short max, char *str); /* __NLA */ int movetolayer_buts (unsigned int *lay, char *title); int movetolayer_short_buts (short *lay, char *title); diff --git a/source/blender/src/toolbox.c b/source/blender/src/toolbox.c index 98634271e92..1cc4a8fd31c 100644 --- a/source/blender/src/toolbox.c +++ b/source/blender/src/toolbox.c @@ -291,13 +291,14 @@ short button(short *var, short min, short max, char *str) return 0; } -short sbutton(char *var, float min, float max, char *str) +short sbutton(char *var, short min, short max, char *str) { uiBlock *block; ListBase listb={0, 0}; short x1,y1; short mval[2], ret=0; - + char *editvar = NULL; /* dont edit the original text, incase we cancel the popup */ + if(min>max) min= max; getmouseco_sc(mval); @@ -313,7 +314,10 @@ short sbutton(char *var, float min, float max, char *str) x1=mval[0]-250; y1=mval[1]-20; - uiDefButC(block, TEX, 32766, str, x1+5,y1+10,225,20, var,(float)min,(float)max, 0, 0, ""); + editvar = MEM_callocN(max, "sbutton"); + BLI_strncpy(editvar, var, max); + + uiDefButC(block, TEX, 32766, str, x1+5,y1+10,225,20, editvar,(float)min,(float)max, 0, 0, ""); uiDefBut(block, BUT, 32767, "OK", x1+236,y1+10,25,20, NULL, 0, 0, 0, 0, ""); uiBoundsBlock(block, 5); @@ -321,7 +325,12 @@ short sbutton(char *var, float min, float max, char *str) mainqenter_ext(BUT_ACTIVATE, 32766, 0); /* note, button id '32766' is asking for errors some day! */ ret= uiDoBlocks(&listb, 0, 0); - if(ret==UI_RETURN_OK) return 1; + if(ret==UI_RETURN_OK) { + BLI_strncpy(var, editvar, max); + MEM_freeN(editvar); + return 1; + } + MEM_freeN(editvar); return 0; } |