ScrolledWindow和wx.EVT_LEAVE_WINDOW

时间:2021-12-23 07:11:57

I have a frame with a textctrl. When the mouse enters the textctrl (EVT_ENTER_WINDOW) I show a PopupWindow on top of the textctrl, and when the mouse leaves the popup (EVT_LEAVE_WINDOW) I hide it again.

我有一个带textctrl的框架。当鼠标进入textctrl(EVT_ENTER_WINDOW)时,我在textctrl上显示一个PopupWindow,当鼠标离开弹出窗口(EVT_LEAVE_WINDOW)时,我再次隐藏它。

Everything works fine, except when inside the PopupWindow there's a ScrolledWindow with shown scrollbars. The EVT_LEAVE_WINDOW gets fired when I move the mouse on top of a scrollbar, so it looks like wxPython thinks the scrollbars are not part of the scrolledwindow.. :/ I tried binding the event to the popup or the scrollwindow itself, but nothing changes.. Is there a way I could get around this?

一切正常,除了在PopupWindow内部有一个显示滚动条的ScrolledWindow。当我在滚动条顶部移动鼠标时EVT_LEAVE_WINDOW被触发,所以看起来wxPython认为滚动条不是滚动窗口的一部分..:/我尝试将事件绑定到弹出窗口或滚动窗口本身,但没有任何变化。我有办法解决这个问题吗?

Many thanks!

(wxPython 2.8.8.0 on Xubuntu 8.10)

(Xubuntu 8.10上的wxPython 2.8.8.0)

2 个解决方案

#1


Since tooltips normally disappear when the user moves the mouse you could also bind to EVT_MOTION instead of EVT_LEAVE_WINDOW and hide the tooltip when the user moves the mouse.

由于工具提示通常在用户移动鼠标时消失,您还可以绑定到EVT_MOTION而不是EVT_LEAVE_WINDOW,并在用户移动鼠标时隐藏工具提示。

#2


Robin Dunn told me: "the same thing would happen with any other widgets that are on the scrolled window, just as the frame will get a EVT_LEAVE_WINDOW when the mouse moves into the scrolled window (assuming some portion of the frame was visible so it could have received an enter window event too)"

Robin Dunn告诉我:“滚动窗口上的任何其他小部件都会发生同样的事情,就像当鼠标移动到滚动窗口时框架将获得EVT_LEAVE_WINDOW(假设框架的某些部分是可见的,所以它可以也收到了一个输入窗口事件)“

#1


Since tooltips normally disappear when the user moves the mouse you could also bind to EVT_MOTION instead of EVT_LEAVE_WINDOW and hide the tooltip when the user moves the mouse.

由于工具提示通常在用户移动鼠标时消失,您还可以绑定到EVT_MOTION而不是EVT_LEAVE_WINDOW,并在用户移动鼠标时隐藏工具提示。

#2


Robin Dunn told me: "the same thing would happen with any other widgets that are on the scrolled window, just as the frame will get a EVT_LEAVE_WINDOW when the mouse moves into the scrolled window (assuming some portion of the frame was visible so it could have received an enter window event too)"

Robin Dunn告诉我:“滚动窗口上的任何其他小部件都会发生同样的事情,就像当鼠标移动到滚动窗口时框架将获得EVT_LEAVE_WINDOW(假设框架的某些部分是可见的,所以它可以也收到了一个输入窗口事件)“