Don't change focus from project tree to editor when selecting file with enter key

This commit is contained in:
Veronica K. B. Olsen
2020-06-02 09:25:52 +02:00
parent 2bd2c81eae
commit 6cd76ff60b
+6 -4
View File
@@ -466,14 +466,15 @@ class GuiMain(QMainWindow):
self.docEditor.clearEditor() self.docEditor.clearEditor()
return True return True
def openDocument(self, tHandle, tLine=None): def openDocument(self, tHandle, tLine=None, changeFocus=True):
"""Open a specific document, optionally at a given line. """Open a specific document, optionally at a given line.
""" """
if self.hasProject: if self.hasProject:
self.closeDocument() self.closeDocument()
self.tabWidget.setCurrentWidget(self.splitView) self.tabWidget.setCurrentWidget(self.splitView)
if self.docEditor.loadText(tHandle, tLine): if self.docEditor.loadText(tHandle, tLine):
self.docEditor.setFocus() if changeFocus:
self.docEditor.setFocus()
self.theProject.setLastEdited(tHandle) self.theProject.setLastEdited(tHandle)
self.treeView.setSelectedHandle(tHandle) self.treeView.setSelectedHandle(tHandle)
else: else:
@@ -1035,7 +1036,8 @@ class GuiMain(QMainWindow):
def _treeKeyPressReturn(self): def _treeKeyPressReturn(self):
"""The user pressed return an item in the tree. If it is a file, """The user pressed return an item in the tree. If it is a file,
we open it. Otherwise, we do nothing. we open it. Otherwise, we do nothing. Pressing return does not
change focus to the editor as double click does.
""" """
tHandle = self.treeView.getSelectedHandle() tHandle = self.treeView.getSelectedHandle()
logger.verbose("User pressed return on tree item with handle %s" % tHandle) logger.verbose("User pressed return on tree item with handle %s" % tHandle)
@@ -1043,7 +1045,7 @@ class GuiMain(QMainWindow):
if nwItem is not None: if nwItem is not None:
if nwItem.itemType == nwItemType.FILE: if nwItem.itemType == nwItemType.FILE:
logger.verbose("Requested item %s is a file" % tHandle) logger.verbose("Requested item %s is a file" % tHandle)
self.openDocument(tHandle) self.openDocument(tHandle, changeFocus=False)
else: else:
logger.verbose("Requested item %s is a folder" % tHandle) logger.verbose("Requested item %s is a folder" % tHandle)
return return