Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
N
noVNC
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
rasky
noVNC
Commits
0bb6a8c5
Commit
0bb6a8c5
authored
Apr 04, 2014
by
samhed
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes issue 344 - problem with backspace on Android.
parent
de8edde4
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
24 deletions
+66
-24
ui.js
include/ui.js
+66
-24
No files found.
include/ui.js
View file @
0bb6a8c5
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
// Load supporting scripts
// Load supporting scripts
window
.
onscriptsload
=
function
()
{
UI
.
load
();
};
window
.
onscriptsload
=
function
()
{
UI
.
load
();
};
window
.
onload
=
function
()
{
UI
.
keyboardinputReset
();
};
Util
.
load_scripts
([
"webutil.js"
,
"base64.js"
,
"websock.js"
,
"des.js"
,
Util
.
load_scripts
([
"webutil.js"
,
"base64.js"
,
"websock.js"
,
"des.js"
,
"keysymdef.js"
,
"keyboard.js"
,
"input.js"
,
"display.js"
,
"keysymdef.js"
,
"keyboard.js"
,
"input.js"
,
"display.js"
,
"jsunzip.js"
,
"rfb.js"
,
"keysym.js"
]);
"jsunzip.js"
,
"rfb.js"
,
"keysym.js"
]);
...
@@ -26,6 +27,8 @@ popupStatusOpen : false,
...
@@ -26,6 +27,8 @@ popupStatusOpen : false,
clipboardOpen
:
false
,
clipboardOpen
:
false
,
keyboardVisible
:
false
,
keyboardVisible
:
false
,
hideKeyboardTimeout
:
null
,
hideKeyboardTimeout
:
null
,
lastKeyboardinput
:
null
,
defaultKeyboardinputLen
:
100
,
extraKeysVisible
:
false
,
extraKeysVisible
:
false
,
ctrlOn
:
false
,
ctrlOn
:
false
,
altOn
:
false
,
altOn
:
false
,
...
@@ -807,7 +810,8 @@ showKeyboard: function() {
...
@@ -807,7 +810,8 @@ showKeyboard: function() {
l
=
kbi
.
value
.
length
;
l
=
kbi
.
value
.
length
;
if
(
UI
.
keyboardVisible
===
false
)
{
if
(
UI
.
keyboardVisible
===
false
)
{
kbi
.
focus
();
kbi
.
focus
();
kbi
.
setSelectionRange
(
l
,
l
);
// Move the caret to the end
try
{
kbi
.
setSelectionRange
(
l
,
l
);
}
// Move the caret to the end
catch
(
err
)
{}
// setSelectionRange is undefined in Google Chrome
UI
.
keyboardVisible
=
true
;
UI
.
keyboardVisible
=
true
;
skb
.
className
=
"noVNC_status_button_selected"
;
skb
.
className
=
"noVNC_status_button_selected"
;
}
else
if
(
UI
.
keyboardVisible
===
true
)
{
}
else
if
(
UI
.
keyboardVisible
===
true
)
{
...
@@ -828,33 +832,71 @@ keepKeyboard: function() {
...
@@ -828,33 +832,71 @@ keepKeyboard: function() {
}
}
},
},
// When keypress events are left uncought, catch the input events from
keyboardinputReset
:
function
()
{
// the keyboardinput element instead and send the corresponding key events.
var
kbi
=
$D
(
'keyboardinput'
);
kbi
.
value
=
Array
(
UI
.
defaultKeyboardinputLen
).
join
(
"_"
);
UI
.
lastKeyboardinput
=
kbi
.
value
;
},
// When normal keyboard events are left uncought, use the input events from
// the keyboardinput element instead and generate the corresponding key events.
// This code is required since some browsers on Android are inconsistent in
// sending keyCodes in the normal keyboard events when using on screen keyboards.
keyInput
:
function
(
event
)
{
keyInput
:
function
(
event
)
{
var
elem
,
input
,
len
;
var
newValue
,
oldValue
,
newLen
,
oldLen
;
elem
=
$D
(
'keyboardinput'
);
newValue
=
event
.
target
.
value
;
input
=
event
.
target
.
value
;
oldValue
=
UI
.
lastKeyboardinput
;
len
=
(
elem
.
selectionStart
>
input
.
length
)
?
elem
.
selectionStart
:
input
.
length
;
try
{
if
(
len
<
1
)
{
// something removed?
// Try to check caret position since whitespace at the end
UI
.
rfb
.
sendKey
(
0xff08
);
// send BACKSPACE
// will not be considered by value.length in some browsers
}
else
if
(
len
>
1
)
{
// new input?
newLen
=
Math
.
max
(
event
.
target
.
selectionStart
,
newValue
.
length
);
for
(
var
i
=
len
-
1
;
i
>
0
;
i
-=
1
)
{
}
catch
(
err
)
{
// HTML does not consider trailing whitespaces as a part of the string
// selectionStart is undefined in Google Chrome
// and they are therefore undefined.
newLen
=
newValue
.
length
;
if
(
input
[
len
-
i
]
!==
undefined
)
{
}
UI
.
rfb
.
sendKey
(
input
.
charCodeAt
(
len
-
i
));
// send charCode
oldLen
=
oldValue
.
length
;
}
else
{
UI
.
rfb
.
sendKey
(
0x0020
);
// send SPACE
var
backspaces
;
}
var
inputs
=
newLen
-
oldLen
;
if
(
inputs
<
0
)
backspaces
=
-
inputs
;
else
backspaces
=
0
;
// Compare the old string with the new to account for
// text-corrections or other input that modify existing text
for
(
var
i
=
0
;
i
<
Math
.
min
(
oldLen
,
newLen
);
i
++
)
{
if
(
newValue
.
charAt
(
i
)
!=
oldValue
.
charAt
(
i
))
{
inputs
=
newLen
-
i
;
backspaces
=
oldLen
-
i
;
break
;
}
}
}
}
// In order to be able to delete text which has been written in
// Send the key events
// another session there has to always be text in the
for
(
var
i
=
0
;
i
<
backspaces
;
i
++
)
// keyboardinput element with which backspace can interact.
UI
.
rfb
.
sendKey
(
XK_BackSpace
);
// We also need to reset the input field text to avoid overflow.
for
(
var
i
=
newLen
-
inputs
;
i
<
newLen
;
i
++
)
elem
.
value
=
'
\
u00a0'
;
UI
.
rfb
.
sendKey
(
newValue
.
charCodeAt
(
i
));
// Control the text content length in the keyboardinput element
if
(
newLen
>
2
*
UI
.
defaultKeyboardinputLen
)
{
UI
.
keyboardinputReset
();
}
else
if
(
newLen
<
1
)
{
// There always have to be some text in the keyboardinput
// element with which backspace can interact.
UI
.
keyboardinputReset
();
// This sometimes causes the keyboard to disappear for a second
// but it is required for the android keyboard to recognize that
// text has been added to the field
event
.
target
.
blur
();
// This has to be ran outside of the input handler in order to work
setTimeout
(
function
()
{
UI
.
keepKeyboard
();
},
0
);
}
else
{
UI
.
lastKeyboardinput
=
newValue
;
}
},
},
keyInputBlur
:
function
()
{
keyInputBlur
:
function
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment