mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Replace knownEvents modules with static strings.
This commit is contained in:
@@ -6,9 +6,6 @@ import formattedString = require("text/formatted-string");
|
||||
import observable = require("data/observable");
|
||||
import weakEventListener = require("ui/core/weak-event-listener");
|
||||
|
||||
export module knownEvents {
|
||||
export var tap = "tap";
|
||||
}
|
||||
var textProperty = new dependencyObservable.Property(
|
||||
"text",
|
||||
"Button",
|
||||
@@ -37,6 +34,8 @@ function onFormattedTextPropertyChanged(data: dependencyObservable.PropertyChang
|
||||
|
||||
export class Button extends view.View implements definition.Button {
|
||||
|
||||
public static tapEvent = "tap";
|
||||
|
||||
public static textProperty = textProperty;
|
||||
public static formattedTextProperty = formattedTextProperty;
|
||||
|
||||
@@ -63,7 +62,7 @@ export class Button extends view.View implements definition.Button {
|
||||
if (this.formattedText !== value) {
|
||||
var weakEventOptions: weakEventListener.WeakEventListenerOptions = {
|
||||
targetWeakRef: new WeakRef(this),
|
||||
eventName: observable.knownEvents.propertyChange,
|
||||
eventName: observable.Observable.propertyChangeEvent,
|
||||
sourceWeakRef: new WeakRef(value),
|
||||
handler: this.onFormattedTextChanged,
|
||||
handlerContext: this,
|
||||
|
||||
@@ -33,7 +33,7 @@ export class Button extends common.Button {
|
||||
|
||||
onClick: function (v) {
|
||||
if (this.owner) {
|
||||
this.owner._emit(common.knownEvents.tap);
|
||||
this.owner._emit(common.Button.tapEvent);
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
26
ui/button/button.d.ts
vendored
26
ui/button/button.d.ts
vendored
@@ -7,13 +7,6 @@ declare module "ui/button" {
|
||||
import view = require("ui/core/view");
|
||||
import formattedString = require("text/formatted-string");
|
||||
|
||||
/**
|
||||
* Known event names.
|
||||
*/
|
||||
export module knownEvents {
|
||||
export var tap: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a standard Button widget.
|
||||
*/
|
||||
@@ -23,6 +16,11 @@ declare module "ui/button" {
|
||||
*/
|
||||
public static textProperty: dependencyObservable.Property;
|
||||
|
||||
/**
|
||||
* String value used when hooking to tap event.
|
||||
*/
|
||||
public static tapEvent: string;
|
||||
|
||||
/**
|
||||
* Gets the native [android widget](http://developer.android.com/reference/android/widget/Button.html) that represents the user interface for this component. Valid only when running on Android OS.
|
||||
*/
|
||||
@@ -43,7 +41,17 @@ declare module "ui/button" {
|
||||
*/
|
||||
formattedText: formattedString.FormattedString;
|
||||
|
||||
on(event: string, callback: (data: observable.EventData) => void);
|
||||
on(event: "tap", callback: (args: observable.EventData) => void);
|
||||
/**
|
||||
* A basic method signature to hook an event listener (shortcut alias to the addEventListener method).
|
||||
* @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change").
|
||||
* @param callback - Callback function which will be executed when event is raised.
|
||||
* @param thisArg - An optional parameter which will be used as `this` context for callback execution.
|
||||
*/
|
||||
on(eventNames: string, callback: (data: observable.EventData) => void, thisArg?: any);
|
||||
|
||||
/**
|
||||
* Raised when a tap event occurs.
|
||||
*/
|
||||
on(event: "tap", callback: (args: observable.EventData) => void, thisArg?: any);
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ class TapHandlerImpl extends NSObject {
|
||||
}
|
||||
|
||||
public tap(args) {
|
||||
this._owner._emit(common.knownEvents.tap);
|
||||
this._owner._emit(common.Button.tapEvent);
|
||||
}
|
||||
|
||||
public static ObjCExposedMethods = {
|
||||
|
||||
Reference in New Issue
Block a user