color: default & binding

This commit is contained in:
YouWei Zhao 2019-01-04 11:38:38 -05:00
parent 91eb0391c5
commit 05290cf9a4
2 changed files with 53 additions and 2 deletions

View File

@ -394,7 +394,7 @@ setText_s
/* setText_s
tooltip : setText设置剧情文本的属性,颜色为RGB三元组或RGBA四元组,打字间隔为剧情文字添加的时间间隔,为整数或不填
helpUrl : https://h5mota.com/games/template/docs/#/event?id=settext%EF%BC%9A%E8%AE%BE%E7%BD%AE%E5%89%A7%E6%83%85%E6%96%87%E6%9C%AC%E7%9A%84%E5%B1%9E%E6%80%A7
default : [null,"","",null,"",null,"",null,null,"","",""]
default : [null,"","",'rgba(255,255,255,1)',"",'rgba(255,255,255,1)',"",'rgba(255,255,255,1)',null,"","",""]
SetTextPosition_List_0 =SetTextPosition_List_0==='null'?'': ', "position": "'+SetTextPosition_List_0+'"';
var colorRe = /^(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d),(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d),(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(,0(\.\d+)?|,1)?$/;
if (EvalString_0) {

View File

@ -314,7 +314,8 @@ Blockly.FieldColour.prototype.createWidget_ = function() {
Blockly.WidgetDiv.hide();
self=this;
// console.log('here')
var self=this;
var pb=self.sourceBlock_
var args = MotaActionBlocks[pb.type].args
var targetf=args[args.indexOf(self.name)-1]
@ -341,4 +342,54 @@ Blockly.FieldColour.prototype.createWidget_ = function() {
});
return picker;
};
Blockly.FieldTextInput.prototype.showInlineEditor_ = function(quietInput) {
Blockly.WidgetDiv.show(this, this.sourceBlock_.RTL, this.widgetDispose_());
var div = Blockly.WidgetDiv.DIV;
// Create the input.
var htmlInput =
goog.dom.createDom(goog.dom.TagName.INPUT, 'blocklyHtmlInput');
htmlInput.setAttribute('spellcheck', this.spellcheck_);
var fontSize =
(Blockly.FieldTextInput.FONTSIZE * this.workspace_.scale) + 'pt';
div.style.fontSize = fontSize;
htmlInput.style.fontSize = fontSize;
Blockly.FieldTextInput.htmlInput_ = htmlInput;
div.appendChild(htmlInput);
htmlInput.value = htmlInput.defaultValue = this.text_;
htmlInput.oldValue_ = null;
this.validate_();
this.resizeEditor_();
if (!quietInput) {
htmlInput.focus();
htmlInput.select();
}
// console.log('here')
var self=this;
var pb=self.sourceBlock_
var args = MotaActionBlocks[pb.type].args
var targetf=args[args.indexOf(self.name)+1]
if(targetf && targetf.slice(0,7)==='Colour_'){
var inputDom = htmlInput;
// var getValue=function(){ // 获得自己的字符串
// return pb.getFieldValue(self.name);
// }
var setValue = function(newValue){ // 设置右边颜色块的css颜色
pb.setFieldValue(newValue, targetf)
}
// 给inputDom绑事件
inputDom.oninput=function(){
var value=inputDom.value
if(/[0-9 ]+,[0-9 ]+,[0-9 ]+(,[0-9. ]+)?/.test(value)){
setValue('rgba('+value+')')
}
}
}
this.bindEvents_(htmlInput);
};