MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / TooltipPopup

Class TooltipPopup

python/examples/custom_tooltip.py:5–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3import binaryninjaui
4
5class TooltipPopup(QWidget):
6 def __init__(self, parent=None):
7 super().__init__(parent, Qt.Window | Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint)
8 self.setFocusPolicy(Qt.StrongFocus)
9 self.setWindowTitle("Tooltip Popup")
10
11 layout = QVBoxLayout()
12 label = QLabel("This is a tooltip-style popup. Press ESC to close.")
13 layout.addWidget(label)
14
15 self.setLayout(layout)
16 self.adjustSize()
17
18 def keyPressEvent(self, event):
19 # This causes the fake tooltip to be closed when you hit Esc
20 if event.key() == Qt.Key_Escape:
21 print("Escape key pressed")
22 self.close()
23 event.accept()
24 else:
25 super().keyPressEvent(event)
26
27 def showEvent(self, event):
28 # This forces the fake tooltip to be focused
29 super().showEvent(event)
30 self.raise_()
31 self.activateWindow()
32 self.setFocus()
33
34 def focusOutEvent(self, event):
35 # This closes the fake tooltip when the user clicks into another UI element
36 print("Lost focus")
37 self.close()
38 super().focusOutEvent(event)
39
40def show_tooltip_popup(parent, pos):
41 tooltip_popup = TooltipPopup(parent)

Callers 1

show_tooltip_popupFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected