From ff1d34fea567e98398098e154ef4135f43cc36ef Mon Sep 17 00:00:00 2001
From: "tatiana.novikova" <tatiana.novikova@demlabs.net>
Date: Thu, 6 Feb 2020 22:38:44 +0300
Subject: [PATCH] [+] Add focus handler to always set focus into console input
 area

---
 .../desktop/Console/DapConsoleRightPanel.qml  |  1 -
 .../desktop/Console/DapConsoleScreen.qml      | 10 ++++++---
 .../Console/DapConsoleScreenForm.ui.qml       | 21 ++++++++++++-------
 3 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleRightPanel.qml b/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleRightPanel.qml
index 9562e91b5..993d7af30 100644
--- a/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleRightPanel.qml
+++ b/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleRightPanel.qml
@@ -25,7 +25,6 @@ DapConsoleRightPanelForm
     //Returns true if item 'someElement' is already exist at list 'someModel'.
     function findElement(someModel, someElement)
     {
-        console.log("someElement.query", someElement.query)
         for(var i = 0; i < someModel.count; ++i)
             if(someModel.get(i).query === someElement.query)
             {
diff --git a/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleScreen.qml b/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleScreen.qml
index e3c0ca3b8..1668bffec 100644
--- a/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleScreen.qml
+++ b/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleScreen.qml
@@ -19,6 +19,8 @@ DapConsoleScreenForm
     {
         //The start point for using history
         consoleHistoryIndex = modelConsoleCommand.count
+        //Set focus to console input
+        consoleInput.forceActiveFocus()
     }
 
     QtObject
@@ -86,9 +88,10 @@ DapConsoleScreenForm
     //Send command fron right history panel
     onHistoryCommandChanged:
     {
-            sendCommand = historyCommand;
-            runCommand(sendCommand)
-            consoleHistoryIndex = modelConsoleCommand.count + 1;
+        sendCommand = historyCommand;
+        runCommand(sendCommand);
+        consoleHistoryIndex = modelConsoleCommand.count + 1;
+        consoleInput.forceActiveFocus();
     }
 
     //Using KeyUp and KeyDown to serf on console history
@@ -107,4 +110,5 @@ DapConsoleScreenForm
         currentCommand = modelConsoleCommand.get(consoleHistoryIndex).query;
         return;
     }
+
 }
diff --git a/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleScreenForm.ui.qml b/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleScreenForm.ui.qml
index eca3734ad..8a11636f9 100644
--- a/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleScreenForm.ui.qml
+++ b/CellFrameDashboardGUI/screen/desktop/Console/DapConsoleScreenForm.ui.qml
@@ -16,6 +16,8 @@ DapAbstractScreen
     property alias currentCommand: consoleCmd.text
     ///@detalis consoleHistoryIndex Index for using KeyUp and KeyDown to the navigation in console history.
     property int consoleHistoryIndex
+    ///@detalis consoleInput Reference to console input area
+    property alias consoleInput: consoleCmd
 
     Rectangle
     {
@@ -26,20 +28,22 @@ DapAbstractScreen
         anchors.rightMargin: 20 * pt
         anchors.bottomMargin: 20 * pt
 
-
         ListView
         {
             id: listViewConsoleCommand
             anchors.top: parent.top
             anchors.left: parent.left
             anchors.right: parent.right
-            height: (contentHeight < consoleRectangle.height - inputCommand.height) ? contentHeight : consoleRectangle.height - inputCommand.height
+            height: (contentHeight < consoleRectangle.height - inputCommand.height) ?
+                        contentHeight :
+                        consoleRectangle.height - inputCommand.height
             clip: true
             model: modelConsoleCommand
             delegate: delegateConsoleCommand
             currentIndex: count - 1
             highlightFollowsCurrentItem: true
             highlightRangeMode: ListView.ApplyRange
+
             DapScrollViewHandling
             {
                 id: scrollHandler
@@ -75,17 +79,20 @@ DapAbstractScreen
                 selectByMouse: true
                 focus: true
                 font: themeConsole.inputCommandFont
-                Keys.onReturnPressed: text.length > 0 ? sendedCommand = text : sendedCommand = ""
-                Keys.onEnterPressed: text.length > 0 ? sendedCommand = text : sendedCommand = ""
+                Keys.onReturnPressed: text.length > 0 ?
+                                          sendedCommand = text :
+                                          sendedCommand = ""
+                Keys.onEnterPressed: text.length > 0 ?
+                                         sendedCommand = text :
+                                         sendedCommand = ""
                 Keys.onUpPressed: (consoleHistoryIndex > 0) ?
                                       consoleHistoryIndex -= 1 :
                                       null
                 Keys.onDownPressed: (consoleHistoryIndex < modelConsoleCommand.count) ?
-                                        consoleHistoryIndex += 1:
+                                        consoleHistoryIndex += 1 :
                                         null
-             }
+            }
         }
-
     }
 
     DapScrollView
-- 
GitLab