mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Merge pull request #690 from NathanaelA/Link_Click_Detection
Link click detection
This commit is contained in:
@@ -10,6 +10,14 @@ function onHtmlPropertyChanged(data: dependencyObservable.PropertyChangeData) {
|
||||
}
|
||||
|
||||
if (types.isString(data.newValue)) {
|
||||
// If the data.newValue actually has a <a...> in it; we need to disable autolink mask
|
||||
// it internally disables the coloring, but then the <a> links won't work.. So to support both
|
||||
// styles of links (html and just text based) we have to manually enable/disable the autolink mask
|
||||
var mask = 15;
|
||||
if (data.newValue.search(/<a\s/i) >= 0) {
|
||||
mask = 0;
|
||||
}
|
||||
view.android.setAutoLinkMask(mask);
|
||||
view.android.setText(<any>android.text.Html.fromHtml(data.newValue));
|
||||
} else {
|
||||
view.android.setText("");
|
||||
@@ -30,5 +38,10 @@ export class HtmlView extends common.HtmlView {
|
||||
|
||||
public _createUI() {
|
||||
this._android = new android.widget.TextView(this._context);
|
||||
// This makes the html <a href...> vwork
|
||||
this._android.setLinksClickable(true);
|
||||
this._android.setMovementMethod(android.text.method.LinkMovementMethod.getInstance());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -27,21 +27,24 @@ function onHtmlPropertyChanged(data: dependencyObservable.PropertyChangeData) {
|
||||
global.moduleMerge(common, exports);
|
||||
|
||||
export class HtmlView extends common.HtmlView {
|
||||
private _ios: UILabel;
|
||||
private _ios: UITextView;
|
||||
|
||||
constructor(options?: definition.Options) {
|
||||
super(options);
|
||||
this._ios = UITextView.new();
|
||||
|
||||
this._ios = new UILabel();
|
||||
this._ios.userInteractionEnabled = true;
|
||||
this._ios.numberOfLines = 0;
|
||||
this._ios.scrollEnabled = false;
|
||||
this._ios.editable = false;
|
||||
this._ios.selectable = true;
|
||||
this._ios.userInteractionEnabled = true;
|
||||
this._ios.dataDetectorTypes = UIDataDetectorTypes.UIDataDetectorTypeAll;
|
||||
}
|
||||
|
||||
get ios(): UILabel {
|
||||
get ios(): UITextView {
|
||||
return this._ios;
|
||||
}
|
||||
|
||||
get _nativeView(): UILabel {
|
||||
get _nativeView(): UITextView {
|
||||
return this._ios;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user