mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 04:41:36 +08:00
Implement page property for ActionItem
This commit is contained in:
@ -186,6 +186,17 @@ export function test_actionItem_inherit_bindingContext_inXML() {
|
||||
TKUnit.assertEqual(actionItem.text, "success", "actionItem.text");
|
||||
};
|
||||
|
||||
export function test_actionItem_page_property_inXML() {
|
||||
var p = <PageModule.Page>builder.parse(
|
||||
"<Page> <Page.actionBar> <ActionBar> <ActionBar.actionItems>" +
|
||||
"<ActionItem text=\"test\" />" +
|
||||
"</ActionBar.actionItems> </ActionBar> </Page.actionBar> </Page>");
|
||||
|
||||
var actionItem = p.actionBar.actionItems.getItemAt(0);
|
||||
|
||||
TKUnit.assertEqual(actionItem.page, p, "actionItem.page");
|
||||
};
|
||||
|
||||
export function test_navigationButton_inherit_bindingContext_inXML() {
|
||||
var p = <PageModule.Page>builder.parse(
|
||||
"<Page> <Page.actionBar> <ActionBar>" +
|
||||
|
@ -297,6 +297,10 @@ export class ActionItem extends bindable.Bindable implements dts.ActionItem {
|
||||
}
|
||||
}
|
||||
|
||||
get page(): pages.Page {
|
||||
return this.actionBar ? this.actionBar.page : undefined;
|
||||
}
|
||||
|
||||
public _raiseTap() {
|
||||
this._emit(ActionItem.tapEvent);
|
||||
}
|
||||
|
5
ui/action-bar/action-bar.d.ts
vendored
5
ui/action-bar/action-bar.d.ts
vendored
@ -128,6 +128,11 @@ declare module "ui/action-bar" {
|
||||
*/
|
||||
actionBar: ActionBar;
|
||||
|
||||
/**
|
||||
* Gets the page that contains the action item.
|
||||
*/
|
||||
page: pages.Page;
|
||||
|
||||
/**
|
||||
* 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").
|
||||
|
Reference in New Issue
Block a user