Skip to content

Commit b296d16

Browse files
committed
add richtext br
1 parent ce0998d commit b296d16

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

ext/NodeRichText.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ let NodeRichText = ccui.RichText.extend({
2626
this.parseText(this._text)
2727
},
2828

29+
addNewLineElement: function() {
30+
var re = ccui.RichElementNewLine.create(1, this._curConfig.color, 255)
31+
this.pushBackElement(re)
32+
},
33+
34+
2935
addRichElement: function (str) {
3036

3137
// cc.FontDefinition = function (properties) {
@@ -144,6 +150,8 @@ let NodeRichText = ccui.RichText.extend({
144150
this._curConfig.fontSize = this._originConfig.fontSize
145151
} else if (value == '/of') {
146152
this._curConfig.osize = this._originConfig.osize
153+
} else if (value == 'br') {
154+
this.addNewLineElement()
147155
}
148156
},
149157

third/html5/cocos2d-js.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53660,6 +53660,17 @@ ccui.RichElementCustomNode = ccui.RichElement.extend({
5366053660
ccui.RichElementCustomNode.create = function (tag, color, opacity, customNode) {
5366153661
return new ccui.RichElementCustomNode(tag, color, opacity, customNode);
5366253662
};
53663+
53664+
ccui.RichElementNewLine = ccui.RichElement.extend({
53665+
ctor: function (tag, color, opacity) {
53666+
ccui.RichElement.prototype.ctor.call(this, tag, color, opacity);
53667+
this._type = ccui.RichElement.NEWLINE;
53668+
}
53669+
});
53670+
53671+
ccui.RichElementNewLine.create = function (tag, color, opacity) {
53672+
return new ccui.RichElementNewLine(tag, color, opacity);
53673+
};
5366353674
ccui.RichText = ccui.Widget.extend({
5366453675
_formatTextDirty: false,
5366553676
_richElements: null,
@@ -53723,6 +53734,9 @@ ccui.RichText = ccui.Widget.extend({
5372353734
case ccui.RichElement.CUSTOM:
5372453735
elementRenderer = element._customNode;
5372553736
break;
53737+
case ccui.RichElement.NEWLINE:
53738+
this._addNewLine();
53739+
continue;
5372653740
default:
5372753741
break;
5372853742
}
@@ -53747,6 +53761,9 @@ ccui.RichText = ccui.Widget.extend({
5374753761
case ccui.RichElement.CUSTOM:
5374853762
this._handleCustomRenderer(element._customNode);
5374953763
break;
53764+
case ccui.RichElement.NEWLINE:
53765+
this._addNewLine();
53766+
continue;
5375053767
default:
5375153768
break;
5375253769
}
@@ -53989,6 +54006,7 @@ ccui.RichText.create = function(){
5398954006
ccui.RichElement.TEXT = 0;
5399054007
ccui.RichElement.IMAGE = 1;
5399154008
ccui.RichElement.CUSTOM = 2;
54009+
ccui.RichElement.NEWLINE = 3;
5399254010
ccui.ScrollViewBar = ccui.ProtectedNode.extend({
5399354011
_parentScroll: null,
5399454012
_direction: null,

0 commit comments

Comments
 (0)