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:
@@ -110,18 +110,14 @@ function pageFromBuilder(moduleNamePath: string, moduleExports: any): pages.Page
|
||||
return page;
|
||||
}
|
||||
|
||||
export module knownEvents {
|
||||
export module android {
|
||||
export var optionSelected = "optionSelected";
|
||||
}
|
||||
}
|
||||
|
||||
interface NavigationContext {
|
||||
entry: definition.BackstackEntry;
|
||||
isBackNavigation: boolean;
|
||||
}
|
||||
|
||||
export class Frame extends view.CustomLayoutView implements definition.Frame {
|
||||
public static androidOptionSelectedEvent = "optionSelected";
|
||||
|
||||
private _navigationQueue: Array<NavigationContext>;
|
||||
private _backStack: Array<definition.BackstackEntry>;
|
||||
public _currentEntry: definition.BackstackEntry;
|
||||
|
||||
@@ -481,13 +481,13 @@ class NativeActivity extends com.tns.NativeScriptActivity {
|
||||
}
|
||||
|
||||
onOptionsItemSelected(menuItem: android.view.IMenuItem) {
|
||||
if (!this.androidFrame.hasListeners(frameCommon.knownEvents.android.optionSelected)) {
|
||||
if (!this.androidFrame.hasListeners(frameCommon.Frame.androidOptionSelectedEvent)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var data: definition.AndroidOptionEventData = {
|
||||
handled: false,
|
||||
eventName: frameCommon.knownEvents.android.optionSelected,
|
||||
eventName: frameCommon.Frame.androidOptionSelectedEvent,
|
||||
item: menuItem,
|
||||
object: this.androidFrame
|
||||
}
|
||||
|
||||
33
ui/frame/frame.d.ts
vendored
33
ui/frame/frame.d.ts
vendored
@@ -12,6 +12,11 @@ declare module "ui/frame" {
|
||||
* Nested frames are supported, enabling hierarchical navigation scenarios.
|
||||
*/
|
||||
export class Frame extends view.View {
|
||||
/**
|
||||
* String value used when hooking to androidOptionSelected event (prefix `android` states that this event is available only in Android).
|
||||
*/
|
||||
public static androidOptionSelectedEvent: string;
|
||||
|
||||
/**
|
||||
* Navigates to the previous entry (if any) in the back stack.
|
||||
*/
|
||||
@@ -86,6 +91,19 @@ declare module "ui/frame" {
|
||||
_processNavigationQueue(page: pages.Page);
|
||||
_invalidateOptionsMenu();
|
||||
//@endprivate
|
||||
|
||||
/**
|
||||
* 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: (args: observable.EventData) => void, thisArg?: any);
|
||||
|
||||
/**
|
||||
* Raised when native android [onOptionsItemSelected method](http://developer.android.com/reference/android/app/Activity.html#onOptionsItemSelected(android.view.MenuItem)) is called.
|
||||
*/
|
||||
on(event: "optionSelected", callback: (args: observable.EventData) => void, thisArg?: any);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -214,19 +232,4 @@ declare module "ui/frame" {
|
||||
*/
|
||||
navBarVisibility: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encapsulates the events raised by the Frame object.
|
||||
*/
|
||||
module knownEvents {
|
||||
/**
|
||||
* Encapsulates the events raised by the android part of the Frame.
|
||||
*/
|
||||
module android {
|
||||
/**
|
||||
* Raised when the native [onOptionsItemSelected method](http://developer.android.com/reference/android/app/Activity.html#onOptionsItemSelected(android.view.MenuItem)) is called.
|
||||
*/
|
||||
export var optionSelected: string;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user