Skip to content
An plugin that adds a pop-up menu to NativeScript
TypeScript Shell JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github first commit Sep 13, 2018
demo
publish
screenshots
src Bump js-yaml from 3.12.0 to 3.13.1 in /src Jun 15, 2019
.directory fix travis Apr 24, 2019
.gitignore updating .gitignore to exclude android binary Aug 10, 2019
.travis.yml fix travis Apr 24, 2019
LICENSE.md first commit Sep 13, 2018
README.md Update README.md Aug 10, 2019
tslint.json

README.md

nativescript-menu Build Status

A plugin that adds a pop-up menu to NativeScript

Installation

From your command prompt/terminal go to your app's root folder and execute:

tns plugin add nativescript-menu

Demo

Android iOS
screenshot 1 screenshot 2

Usage

<Page xmlns="http://schemas.nativescript.org/tns.xsd" loaded="pageLoaded" class="page"
  xmlns:ui="nativescript-menu">
  <StackLayout class="p-20">
    <Button id="menuBtn" text="getMenu" tap="{{ buttonTap }}"/>
  </StackLayout>
</Page>
import { Menu } from "nativescript-menu";

export class HelloWorldModel extends Observable {
  public message: string;
  private menu: Menu;

  constructor(public page: Page) {
    super();
  }

  buttonTap() {
    Menu.popup({
      view: this.page.getViewById("menuBtn"),
      actions: ["Example", "NativeScript", "Menu"]
    })
      .then(action => {
        alert(action.id + " - " + action.title);
      })
      .catch(console.log);
  }
}

with custom options

import { Menu } from "nativescript-menu";

export class HelloWorldModel extends Observable {
  public message: string;
  private menu: Menu;

  constructor(public page: Page) {
    super();
  }

  buttonTap() {
    Menu.popup({
      view: this.page.getViewById("menuBtn"),
      actions: [
        { id: "one", title: "Example" },
        { id: "two", title: "NativeScript", customOption: "Hello" },
        { id: "three", title: "Menu" }
      ]
    })
      .then(action => {
        alert(JSON.stringify(action));
      })
      .catch(console.log);
  }
}

API

  • MenuOptions
export interface MenuOptions {
  title?: string; // IOS Only
  message?: string; // IOS Only
  view: View;
  actions: object[] | string[];
  cancelButtonText?: string; // IOS Only
}
Method Description
popup(options: MenuOptions): Promise<{id: number, title: string} | actionObject | boolean> Create a pop-up menu and show it
You can’t perform that action at this time.