1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-14 02:06:29 +00:00

popup will emit ipc event for main process to write clipboard

This commit is contained in:
Rokt33r
2015-06-06 21:31:43 +09:00
parent bacccbadf3
commit 010ee6a711
3 changed files with 29 additions and 8 deletions

View File

@@ -2,15 +2,14 @@
var remote = require('remote') var remote = require('remote')
var ipc = require('ipc') var ipc = require('ipc')
var clipboard = require('clipboard')
var SEARCH_INPUT = 1 var SEARCH_INPUT = 1
var RESULT_LIST = 2 var RESULT_LIST = 2
var RESULT_CONTROL = 3 var RESULT_CONTROL = 3
var RESULT_CONTENT = 4 var RESULT_CONTENT = 4
var btnClipboard = document.getElementById('btnClipboard') // var btnClipboard = document.getElementById('btnClipboard')
var btnEdit = document.getElementById('btnEdit') // var btnEdit = document.getElementById('btnEdit')
var btnShare = document.getElementById('btnShare') // var btnShare = document.getElementById('btnShare')
var aceView = document.getElementById('aceView') var aceView = document.getElementById('aceView')
angular.module('codexen.popup', [ angular.module('codexen.popup', [
@@ -105,8 +104,7 @@ angular.module('codexen.popup', [
switch ($scope.isFocusing) { switch ($scope.isFocusing) {
case RESULT_LIST: case RESULT_LIST:
console.log($scope.selectedItem.content) console.log($scope.selectedItem.content)
clipboard.writeText($scope.selectedItem.content) ipc.send('writeCode', $scope.selectedItem.content)
hidePopUp()
break break
} }
e.preventDefault() e.preventDefault()

24
main.js
View File

@@ -12,6 +12,10 @@ app.on('window-all-closed', function () {
if (process.platform !== 'darwin') app.quit() if (process.platform !== 'darwin') app.quit()
}) })
var robot = require('robotjs')
var clipboard = require('clipboard')
var Tray = require('tray') var Tray = require('tray')
var appIcon = null var appIcon = null
@@ -19,7 +23,13 @@ app.on('ready', function () {
appIcon = new Tray('./icon.png') appIcon = new Tray('./icon.png')
appIcon.setToolTip('This is my application.') appIcon.setToolTip('This is my application.')
mainWindow = new BrowserWindow({width: 800, height: 600}) mainWindow = new BrowserWindow({
width: 800,
height: 600,
'web-preferences': {
'overlay-scrollbars': true
}
})
mainWindow.loadUrl('file://' + __dirname + '/electron_build/index.html') mainWindow.loadUrl('file://' + __dirname + '/electron_build/index.html')
@@ -36,7 +46,10 @@ app.on('ready', function () {
width: 600, width: 600,
height: 400, height: 400,
show: false, show: false,
frame: false frame: false,
'web-preferences': {
'overlay-scrollbars': true
}
}) })
popUpWindow.loadUrl('file://' + __dirname + '/electron_build/electron/popup/index.html') popUpWindow.loadUrl('file://' + __dirname + '/electron_build/electron/popup/index.html')
@@ -74,6 +87,13 @@ app.on('ready', function () {
ipc.on('hidePopUp', function () { ipc.on('hidePopUp', function () {
hidePopUp() hidePopUp()
}) })
ipc.on('writeCode', function (e, code) {
clipboard.writeText(code)
// setTimeout(function () {
// robot.typeString(code)
// }, 200)
hidePopUp()
})
var fromMain var fromMain
// Register a 'ctrl+x' shortcut listener. // Register a 'ctrl+x' shortcut listener.

View File

@@ -35,12 +35,15 @@
"angular-ui-router": "^0.2.15", "angular-ui-router": "^0.2.15",
"font-awesome": "^4.3.0", "font-awesome": "^4.3.0",
"moment": "^2.10.3", "moment": "^2.10.3",
"robotjs": "^0.1.2",
"satellizer": "^0.10.1", "satellizer": "^0.10.1",
"ui-select": "^0.11.2" "ui-select": "^0.11.2"
}, },
"devDependencies": { "devDependencies": {
"bootstrap-sass": "^3.3.4", "bootstrap-sass": "^3.3.4",
"del": "^1.2.0", "del": "^1.2.0",
"electron-prebuilt": "^0.27.2",
"electron-rebuild": "^0.2.1",
"globby": "^2.0.0", "globby": "^2.0.0",
"gulp": "^3.8.11", "gulp": "^3.8.11",
"gulp-angular-templatecache": "^1.6.0", "gulp-angular-templatecache": "^1.6.0",