mirror of
https://github.com/antos-rde/antosdk-apps.git
synced 2025-08-28 14:52:45 +02:00
RemoteDesktop: sync clipboard between local and remote
This commit is contained in:
@@ -262,8 +262,13 @@ class WVNC
|
||||
|
||||
sendTextAsClipboard: (text) ->
|
||||
return unless @socket
|
||||
console.log "send ", text
|
||||
@socket.send (@buildCommand 0x07, text)
|
||||
# send ctrl-v to paste
|
||||
charcode = 'v'.charCodeAt 0
|
||||
@sendKeyEvent 0xFFE3, 1 # CTRL down
|
||||
@sendKeyEvent charcode, 1 # v down
|
||||
@sendKeyEvent charcode, 0 # v up
|
||||
@sendKeyEvent 0xFFE3, 0 # CTRL up
|
||||
|
||||
oncredential: () ->
|
||||
return new Promise (resolve, reject) ->
|
||||
|
@@ -88,6 +88,8 @@ class RemoteDesktop extends this.OS.application.BaseApplication
|
||||
@client = new WVNC {
|
||||
element: @canvas
|
||||
}
|
||||
@bindKey "CTRL-SHIFT-V", (e) =>
|
||||
@pasteText()
|
||||
@client.onerror = (m) =>
|
||||
@error m
|
||||
@showConnectionDialog()
|
||||
@@ -103,7 +105,9 @@ class RemoteDesktop extends this.OS.application.BaseApplication
|
||||
}
|
||||
.then (d) ->
|
||||
r(d)
|
||||
|
||||
@client.oncopy = (text) =>
|
||||
@_api.setClipboard text
|
||||
|
||||
@client.oncredential = () =>
|
||||
return new Promise (r,e) =>
|
||||
@openDialog new CredentialDialog, { title: __("User credential") }
|
||||
@@ -114,6 +118,23 @@ class RemoteDesktop extends this.OS.application.BaseApplication
|
||||
@client.init().then () =>
|
||||
@showConnectionDialog()
|
||||
|
||||
pasteText: () ->
|
||||
return unless @client
|
||||
cb = (text) =>
|
||||
return unless text and text isnt ""
|
||||
@client.sendTextAsClipboard text
|
||||
|
||||
@_api.getClipboard()
|
||||
.then (text) =>
|
||||
cb(text)
|
||||
.catch (e) =>
|
||||
@error __("Unable to paste"), e
|
||||
#ask for user to enter the text manually
|
||||
@openDialog("TextDialog", { title: "Paste text"})
|
||||
.then (text) =>
|
||||
cb(text)
|
||||
.catch (err) => @error err.toString(), err
|
||||
|
||||
setScale: () ->
|
||||
return unless @client and @client.resolution
|
||||
w = $(@container).width()
|
||||
|
Reference in New Issue
Block a user