← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

[Merge] lp:~nikwen/ubuntu-calculator-app/delete-backspace-copy-fix into lp:ubuntu-calculator-app

 

Niklas Wenzel has proposed merging lp:~nikwen/ubuntu-calculator-app/delete-backspace-copy-fix into lp:ubuntu-calculator-app.

Commit message:
Fix physical delete and backspace keys, implement proper copy support for the desktop

Requested reviews:
  Ubuntu Calculator Developers (ubuntu-calculator-dev)

For more details, see:
https://code.launchpad.net/~nikwen/ubuntu-calculator-app/delete-backspace-copy-fix/+merge/266660

Fix physical delete and backspace keys, implement proper copy support for the desktop

(This is one of two MPs as a result of splitting https://code.launchpad.net/~nikwen/ubuntu-calculator-app/delete-copy-paste-fix/+merge/264621)
-- 
Your team Ubuntu Calculator Developers is requested to review the proposed merge of lp:~nikwen/ubuntu-calculator-app/delete-backspace-copy-fix into lp:ubuntu-calculator-app.
=== modified file 'app/ubuntu-calculator-app.qml'
--- app/ubuntu-calculator-app.qml	2015-07-04 20:07:48 +0000
+++ app/ubuntu-calculator-app.qml	2015-08-02 12:20:04 +0000
@@ -295,15 +295,8 @@
 
             // Some special keys like backspace captured in TextField,
             // are for some reason not sent to the application but to the text input
-            Keys.onPressed: {                 
-                keyboardLoader.item.pressedKey = event.key;
-                keyboardLoader.item.pressedKeyText = event.text;
-            }
-
-            Keys.onReleased: {
-                keyboardLoader.item.pressedKey = -1;
-                keyboardLoader.item.pressedKeyText = "";
-            }
+            Keys.onPressed: textInputField.keyPress(event)
+            Keys.onReleased: textInputField.keyRelease(event)
 
             Header {
                 id: header
@@ -640,17 +633,23 @@
 
                         // Need to capture special keys like backspace here,
                         // as they are for some reason not sent to the application but to the text input
-                        Keys.onPressed: { 
-                            // Don't press calculator's visual keys, when modifiers are pressed
-                            // to allow work keyboard shortcuts (eg. Ctrl+C)
-                            if (event.modifiers & Qt.NoModifier) {
-                                
+                        Keys.onPressed: keyPress(event)
+                        Keys.onReleased: keyRelease(event)
+
+                        function keyPress(event) {
+                            if (!(event.modifiers & Qt.ControlModifier || event.modifiers & Qt.AltModifier)) { // Shift needs to be passed through as it may be required for some special keys
                                 keyboardLoader.item.pressedKey = event.key;
                                 keyboardLoader.item.pressedKeyText = event.text;
+                            } else if (event.modifiers & Qt.ControlModifier) {
+                                if (event.key === Qt.Key_C) { // Copy action
+                                    var mimeData = Clipboard.newData();
+                                    mimeData.text = textInputField.selectedText;
+                                    Clipboard.push(mimeData);
+                                }
                             }
                         }
 
-                        Keys.onReleased: {
+                        function keyRelease(event) {
                             keyboardLoader.item.pressedKey = -1;
                             keyboardLoader.item.pressedKeyText = "";
                         }


Follow ups