TransformationMethod set to null in order to apply formattedText

This commit is contained in:
Vladimir Enchev
2016-03-25 12:05:41 +02:00
parent f42b13322a
commit b6e046e884
2 changed files with 60 additions and 8 deletions

View File

@ -12,6 +12,16 @@
</FormattedString>
</Label.formattedText>
</Label>
<Label>
<Label.formattedText>
<FormattedString>
<FormattedString.spans>
<Span text="label" fontAttributes="Bold" foregroundColor="#0000ff" />
<Span text="Label" fontAttributes="Italic" foregroundColor="#00ff00" />
</FormattedString.spans>
</FormattedString>
</Label.formattedText>
</Label>
<Button text="buttonButton" style="text-transform: uppercase; text-decoration: underline line-through;" />
<Button style="text-transform: uppercase; text-decoration: underline line-through;">
@ -24,6 +34,16 @@
</FormattedString>
</Button.formattedText>
</Button>
<Button>
<Button.formattedText>
<FormattedString>
<FormattedString.spans>
<Span text="button" fontAttributes="Bold" foregroundColor="#0000ff" />
<Span text="Button" fontAttributes="Italic" foregroundColor="#00ff00" />
</FormattedString.spans>
</FormattedString>
</Button.formattedText>
</Button>
<TextField text="textField" style="text-transform: uppercase; text-decoration: underline line-through;" />
<TextField style="text-transform: uppercase; text-decoration: underline line-through;">
@ -36,6 +56,16 @@
</FormattedString>
</TextField.formattedText>
</TextField>
<TextField>
<TextField.formattedText>
<FormattedString>
<FormattedString.spans>
<Span text="text" fontAttributes="Bold" foregroundColor="#0000ff" />
<Span text="Field" fontAttributes="Italic" foregroundColor="#00ff00" />
</FormattedString.spans>
</FormattedString>
</TextField.formattedText>
</TextField>
<TextView text="textView" style="text-transform: uppercase; text-decoration: underline line-through;" />
<TextView style="text-transform: uppercase; text-decoration: underline line-through;">
@ -48,6 +78,16 @@
</FormattedString>
</TextView.formattedText>
</TextView>
<TextView>
<TextView.formattedText>
<FormattedString>
<FormattedString.spans>
<Span text="text" fontAttributes="Bold" foregroundColor="#0000ff" />
<Span text="View" fontAttributes="Italic" foregroundColor="#00ff00" />
</FormattedString.spans>
</FormattedString>
</TextView.formattedText>
</TextView>
</StackLayout>
</Page>

View File

@ -30,7 +30,7 @@ export class Button extends common.Button {
return that.get();
},
onClick: function (v) {
onClick: function(v) {
if (this.owner) {
this.owner._emit(common.Button.tapEvent);
}
@ -44,9 +44,21 @@ export class Button extends common.Button {
}
}
private _transformationMethod;
public _setFormattedTextPropertyToNative(value) {
var newText = value ? value._formattedText : null;
if (this.android) {
if (newText) {
if (!this._transformationMethod) {
this._transformationMethod = this.android.getTransformationMethod();
}
this.android.setTransformationMethod(null);
} else {
if (this._transformationMethod && !this.android.getTransformationMethod()) {
this.android.setTransformationMethod(this._transformationMethod);
}
}
this.android.setText(newText);
}
}