Coder Social home page Coder Social logo

native-msg-box's Introduction

native-msg-box

Allows you to display a native MessageBox / Dialog.

By native we mean an OS level, not a browser level dialog.

Installing

Have Git installed, just for safety! Run npm install or yarn add or whatever you use and type this as the package name git+https://github.com/mooocow123/native-msg-box or if you want the original module insert package manager install command here native-msg-box. If it doesn't work with yarn 2 or 3, use native-msg-box@git+https://github.com/mooocow123/native-msg-box as the package name instead if you're trying to install this.

Example:

var msgbox = require('native-msg-box');
msgbox.prompt({
  msg: "Hunt the Wumpus?",
  title: "Game"
}, function(err, result) {
  switch (result) {
    case msgbox.Result.YES:
      console.log("pressed yes");
      break;
    case msgbox.Result.NO:
      console.log("pressed no");
      break;
  }
});

API:

  • prompt(options, callback)

    options

    msg {string} REQUIRED The message to display, Example: msg: "Hello World!"

    title {string} optional. Title for dialog (not available on all OSes ... yet?), Example: title: "Hello World The Hello World :)"

    icon {number} optional. Icon for dialog, Example: icon: msgbox.Icon.STOP

    type {number} optional. Type of dialog, Example: type: 2

    Full options example: { msg: "Hello World!", title: "Hello World The Hello World :)", icon: msgbox.Icon.STOP, type: 2 }

    callback

    The callback gets passed an err and a result. At the moment err should always be null. result is one of

    Result.YES
    Result.NO
    

    Why not just a simple true or false? Because the future possibility of more values like Cancel, Retry, etc..

Prerequisites

Currently the Linux version requires wmctrl and zentiy.

To Do

  • Add more dialog types. For example

    • a single string prompt "Enter Name: ____"
    • other buttons like "Ok", "Cancel"

native-msg-box's People

Contributors

greggman avatar mooocow123 avatar mooocow124 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.