bugfix [#30760] edit text property bug
authorDalai Felinto <dfelinto@gmail.com>
Mon, 9 Apr 2012 01:42:44 +0000 (01:42 +0000)
committerDalai Felinto <dfelinto@gmail.com>
Mon, 9 Apr 2012 01:42:44 +0000 (01:42 +0000)
backspace was messing up with utf8 text.
hijacking Blender utf8 functions

tested in CMake but I think scons should work too. No idea about pure 'make'
Happy Easter ;)

source/gameengine/GameLogic/CMakeLists.txt
source/gameengine/GameLogic/SCA_KeyboardSensor.cpp
source/gameengine/GameLogic/SConscript

index 98255bb8b97b9fe9384bdb9e331a23fb88233ce2..64f198f72a077cbb138f6bd8e510e9f7ed87cc9d 100644 (file)
@@ -28,6 +28,7 @@ set(INC
        ../Expressions
        ../Rasterizer
        ../SceneGraph
+       ../../blender/blenlib
        ../../../intern/container
        ../../../intern/moto/include
        ../../../intern/string
index 48237a1b467449ba0d11c8deb5f8e9b1e43b742c..704b244c52ceb483856bba1f9b035728d51674e4 100644 (file)
 #include "StringValue.h"
 #include "SCA_IInputDevice.h"
 
+extern "C" {
+       #include "BLI_string_cursor_utf8.h"
+}
+
 /* ------------------------------------------------------------------------- */
 /* Native functions                                                          */
 /* ------------------------------------------------------------------------- */
@@ -338,7 +342,11 @@ void SCA_KeyboardSensor::AddToTargetProp(int keyIndex)
                                STR_String newprop = tprop->GetText();
                                int oldlength = newprop.Length();
                                if (oldlength >= 1 ) {
-                                       newprop.SetLength(oldlength - 1);
+                                       int newlength=oldlength;
+
+                                       BLI_str_cursor_step_prev_utf8(newprop, NULL, &newlength);
+                                       newprop.SetLength(newlength);
+
                                        CStringValue * newstringprop = new CStringValue(newprop, m_targetprop);
                                        GetParent()->SetProperty(m_targetprop, newstringprop);
                                        newstringprop->Release();
index 62bdbc2954429243685fea9a23af0a3607a2bf40..e01222e81d7a10410b8f6372137360d0d043bb06 100644 (file)
@@ -6,6 +6,7 @@ sources = env.Glob('*.cpp') + env.Glob('Joystick/*.cpp')
 incs = '. #/intern/string #intern/container'
 incs += ' #/source/gameengine/Expressions #/intern/moto/include'
 incs += ' #/source/gameengine/Rasterizer #/source/gameengine/SceneGraph'
+incs += ' #/blender/blenlib'
 
 defs = []