How to use the nw.gui.Clipboard function in nw

To help you get started, we’ve selected a few nw examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github iShift / twister-webkit / interface.js View on Github external
var el = ev.target,
        bTextInput = el.nodeName === 'INPUT' || el.nodeName === 'TEXTAREA',
        iframedoc = getIframeDocument();

    // copy
    menuContext.items[0].enabled = bTextInput || !iframedoc.getSelection().isCollapsed;

    // copy link
    while (!(/^(a|html)$/i).test(el.nodeName)) {
        el = el.parentNode;
    }
    contextURL = 'href' in el ? el.href : '';
    menuContext.items[1].enabled = !!contextURL;

    // paste
    menuContext.items[2].enabled = bTextInput && !!gui.Clipboard.get().get('text');

    menuContext.popup(ev.x, ev.y);
    return false;
}
github SpiderOak / Encryptr / src / app.js View on Github external
// :(, fail to register the |key| or couldn't parse the |key|.
          console.log(msg);
        }
      };
      // Create a shortcut with |option|.
      var shortcut = new gui.Shortcut(option);
      gui.App.registerGlobalHotKey(shortcut);
      // ...but turn it off when not focused
      win.on("blur", function() {
        gui.App.unregisterGlobalHotKey(shortcut);
      });
      win.on("focus", function() {
        gui.App.registerGlobalHotKey(shortcut);
      });

      window.clipboard = gui.Clipboard.get();
      Encryptr.prototype.copyToClipboard = function(text) {
        window.clipboard.set(text, 'text');
      };
      /* jshint node: false */
    } else {
      // Fallback to empty browser polyfill
      Encryptr.prototype.copyToClipboard = function() {};
    }
  };
github rhiokim / haroopad / src / js / pad / viewer / Viewer.js View on Github external
function(inlineStyle, StyleForEmail, UserTheme, DragDrop) {
		var fs = require('fs');
		var path = require('path');

		var iframe = $('#viewer iframe')[0];
		var _viewer = iframe.contentWindow;

		var gui = require('nw.gui'),
			clipboard = gui.Clipboard.get();

		var MIN_FONT_SIZE = 9;
		var MAX_FONT_SIZE = 30;

		var viewerConfig = store.get('Viewer') || {};
			viewerConfig.fontSize = Number(viewerConfig.fontSize || 15);
		var codeConfig = store.get('Code') || {};
		// var customConfig = store.get('Custom') || {};
		// var generalConfig = store.get('General') || {};
		var markdownConfig = store.get('Markdown') || {};

		// var config = option.toJSON();

		// function setTitle() {
		// 	var viewerDoc = iframe.contentDocument.body;
		// 	var el = viewerDoc.querySelectorAll('h1, h2, h3, h4, h5, h6')[0];
github zurp / deprecated-openMou / src / js / core.js View on Github external
/* Globals */
window.currentFile=null;
window.editor=null;
window.simplemode=false;

/* Node imports and WebKit globals */
var gui = require('nw.gui');
var fs = require('fs');
var win=gui.Window.get();
var clipboard = gui.Clipboard.get();
github octalmage / HotGifs / app.js View on Github external
menu.append(new gui.MenuItem(
{
	type: "separator"
}));
menu.append(new gui.MenuItem(
{
	label: "Exit",
	click: function()
	{
		gui.App.quit();
	},
}));
tray.menu = menu;

//Get clipboard reference.
var clipboard = gui.Clipboard.get();

//Uncomment to show dev tools.
//win.showDevTools();

var translate_endpoint = "http://api.giphy.com";
var api_version = "v1";

//Hotkey Stuff
var option = {
	key: "Ctrl+Alt+G",
	active: function()
	{
		showing = 1;
		win.show();

		//Workaround to focus the input after showing.
github hoge1e3 / Tonyu2 / www / js / ide / ImageDetailEditor.js View on Github external
function copyToClipboard(value) {
        if (!WebSite.isNW) return;
        var gui = require('nw.gui');
        var clipboard = gui.Clipboard.get();
        clipboard.set(value, 'text');
    }
github popcorn-official / popcorn-desktop-legacy / src / app / lib / views / player / player.js View on Github external
displayStreamURL: function() {
			var clipboard = require('nw.gui').Clipboard.get();
			clipboard.set($('#video_player video').attr('src'), 'text');
			this.displayOverlayMsg(i18n.__('URL of this stream was copied to the clipboard'));
		},
github davidmerfield / Stroke / app / js / app.js View on Github external
function copytext () {
    if (selectedText()) {
      var clipboard = gui.Clipboard.get(),
          text = selectedText().toString();

      return clipboard.set(text, 'text');
    };
  };
github getcanoe / canoe / src / js / services / nodeWebkitService.js View on Github external
this.writeToClipboard = function (text) {
    var gui = require('nw.gui')
    var clipboard = gui.Clipboard.get()
    return clipboard.set(text)
  }
github streamlink / streamlink-twitch-gui / src / app / nwjs / nwGui.js View on Github external
import nwGui from "nw.gui";


export default nwGui;

export const App = nwGui.App;
export const Clipboard = nwGui.Clipboard;
export const Menu = nwGui.Menu;
export const MenuItem = nwGui.MenuItem;
export const Screen = nwGui.Screen;
export const Shell = nwGui.Shell;
export const Shortcut = nwGui.Shortcut;
export const Tray = nwGui.Tray;
export const Window = nwGui.Window;