Skip to content

Commit 4e776ef

Browse files
committed
Implement editor.lost_focus signal
1 parent 6fd5f03 commit 4e776ef

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

pyqt_code_editor/mixins/base.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class Base:
1515
code_editor_language = 'text'
1616
modification_changed = Signal(object, bool)
1717
received_focus = Signal(object)
18+
lost_focus = Signal(object)
1819

1920
def __init__(self, *args, **kwargs):
2021
# Optionally set the language. This is mainly for generic editors that
@@ -52,6 +53,13 @@ def focusInEvent(self, event):
5253
"""
5354
super().focusInEvent(event)
5455
self.received_focus.emit(self)
56+
57+
def focusOutEvent(self, event):
58+
"""Allows managing widgets, such as the editor panel, to keep track of
59+
which editor is active
60+
"""
61+
super().focusOutEvent(event)
62+
self.lost_focus.emit(self)
5563

5664
def refresh(self):
5765
"""Can be called to indicate that the interface needs to be refreshed,

pyqt_code_editor/mixins/complete.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def wheelEvent(self, event):
9999
self._cm_completion_popup.hide()
100100

101101
def focusOutEvent(self, event):
102-
"""Make sure the calltip doesn't stay open when we scroll the viewport.
102+
"""Make sure the calltip doesn't stay open when the widget loses focus.
103103
"""
104104
super().focusOutEvent(event)
105105
self._cm_hide_calltip()
@@ -516,9 +516,7 @@ def _cm_show_calltip(self, text):
516516
global_pos = global_bottom_left
517517
logger.info("Positioning calltip below cursor.")
518518

519-
print(f'intended position: {global_pos}')
520519
self._cm_calltip_widget.move(global_pos)
521-
print(f'actual position: {self._cm_calltip_widget.pos()}')
522520
self._cm_calltip_widget.show()
523521

524522
def closeEvent(self, event):

0 commit comments

Comments
 (0)