From 7132f6aeb69e6d0414ca133a9e6f9ab341855e01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Neziri=C4=87=20Aldin?= Date: Tue, 16 Jul 2019 09:50:20 +0200 Subject: [PATCH] Check for selection and insert character over selection. --- src/keyboard.vue | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/keyboard.vue b/src/keyboard.vue index a8f9f31..10025e8 100644 --- a/src/keyboard.vue +++ b/src/keyboard.vue @@ -177,7 +177,11 @@ }, insertChar(caret, text, ch) { - text = text.substr(0, caret.start) + ch.toString() + text.substr(caret.start); + if (caret.start < caret.end) { + text = text.substring(0, caret.start) + ch.toString() + text.substring(caret.end); + } else { + text = text.substr(0, caret.start) + ch.toString() + text.substr(caret.start); + } caret.start += ch.length; caret.end = caret.start; return text;