MCPcopy
hub / github.com/PyQt5/PyQt / mouseReleaseEvent

Method mouseReleaseEvent

Demo/WeltHideWindow.py:96–111  ·  view source on GitHub ↗

鼠标弹起事件,这个时候需要判断窗口的左边是否符合贴到左边,顶部,右边一半

(self, event)

Source from the content-addressed store, hash-verified

94 self.move(event.globalPos() - self._pos)
95
96 def mouseReleaseEvent(self, event):
97 """鼠标弹起事件,这个时候需要判断窗口的左边是否符合贴到左边,顶部,右边一半"""
98 super(WeltHideWindow, self).mouseReleaseEvent(event)
99 self._canMove = False
100 pos = self.pos()
101 x = pos.x()
102 y = pos.y()
103 if x < 0:
104 # 隐藏到左边
105 return self.move(1 - self.width(), y)
106 if y < 0:
107 # 隐藏到顶部
108 return self.move(x, 1 - self.height())
109 if x > self._width - self.width() / 2: # 窗口进入右边一半距离
110 # 隐藏到右边
111 return self.move(self._width - 1, y)
112
113 def enterEvent(self, event):
114 """鼠标进入窗口事件,用于弹出显示窗口"""

Callers

nothing calls this directly

Calls 5

yMethod · 0.80
moveMethod · 0.80
xMethod · 0.45
widthMethod · 0.45
heightMethod · 0.45

Tested by

no test coverage detected