[Kst] branches/work/kst/1.6/kst/src/extensions/js

Andrew Walker arwalker at sumusltd.com
Wed Jan 9 20:09:03 CET 2008


SVN commit 758985 by arwalker:

add ability to set string with text rather than just numeric values

 M  +1 -1      bind_label.cpp  
 M  +14 -7     bind_string.cpp  


--- branches/work/kst/1.6/kst/src/extensions/js/bind_label.cpp #758984:758985
@@ -195,7 +195,7 @@
       return (this->*labelProperties[i].get)(exec);
     }
   }
-  
+
   return KstBindBorderedViewObject::get(exec, propertyName);
 }
 
--- branches/work/kst/1.6/kst/src/extensions/js/bind_string.cpp #758984:758985
@@ -145,7 +145,7 @@
       return (this->*stringProperties[i].get)(exec);
     }
   }
-  
+
   return KstBindObject::get(exec, propertyName);
 }
 
@@ -187,16 +187,23 @@
 
 
 void KstBindString::setValue(KJS::ExecState *exec, const KJS::Value& value) {
-  if (value.type() != KJS::NumberType) {
+  if (value.type() == KJS::NumberType) {
+    KstStringPtr s = makeString(_d);
+    if (s) {
+      KstWriteLocker wl(s);
+      s->setValue(value.toString(exec).qstring());
+    }
+  } else if (value.type() == KJS::StringType) {
+    KstStringPtr s = makeString(_d);
+    if (s) {
+      KstWriteLocker wl(s);
+      s->setValue(value.toString(exec).qstring());
+    }
+  } else {
     KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
     exec->setException(eobj);
     return;
   }
-  KstStringPtr s = makeString(_d);
-  if (s) {
-    KstWriteLocker wl(s);
-    s->setValue(value.toString(exec).qstring());
-  }
 }
 
 


More information about the Kst mailing list