forked from NativeScript/NativeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbutton.android.ts
More file actions
52 lines (40 loc) · 1.32 KB
/
button.android.ts
File metadata and controls
52 lines (40 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import common = require("./button-common");
import utils = require("utils/utils")
import dependencyObservable = require("ui/core/dependency-observable");
global.moduleMerge(common, exports);
export class Button extends common.Button {
private _android: android.widget.Button;
private _isPressed: boolean;
constructor() {
super();
this._isPressed = false;
}
get android(): android.widget.Button {
return this._android;
}
public _createUI() {
var that = new WeakRef(this);
this._android = new android.widget.Button(this._context);
this._android.setOnClickListener(new android.view.View.OnClickListener(
<utils.Owned & android.view.View.IOnClickListener>{
get owner() {
return that.get();
},
onClick: function (v) {
if (this.owner) {
this.owner._emit(common.Button.tapEvent);
}
}
}));
}
public _onTextPropertyChanged(data: dependencyObservable.PropertyChangeData) {
if (this.android) {
this.android.setText(data.newValue + "");
}
}
public _setFormattedTextPropertyToNative(value) {
if (this.android) {
this.android.setText(value._formattedText);
}
}
}