在wxpython中使用修饰符进行拖放

发布于 2024-10-14 23:27:48 字数 445 浏览 1 评论 0原文

有没有办法在 wxpython 中的拖放过程中捕获修饰符?在几篇文章中作为旁注提到了它(OLE 方式在wxPython中进行拖放wx.TreeCtrl拖放放置、复制和移动),但这些都没有提到如何捕获这些修饰符。

我知道 CmdDown(),但这需要 EVT_CHAR。有没有办法在拖放(到画布)期间强制使用 EVT_CHAR?

归根结底,我可以使用一些全局钩子,但我知道类似的包中有等效的东西可以让你捕获修饰符。

任何帮助表示赞赏。

Is there a way to capture modifiers during a drag-and-drop in wxpython? It is mentioned in a couple of posts as a sidenote (The OLE way of doing drag&drop in wxPython, wx.TreeCtrl drag and drop, copy and move), but neither of those mentions how to catch these modifiers.

I am aware of CmdDown(), but that requires an EVT_CHAR. Is there a way to force an EVT_CHAR during a drag and drop (to a canvas)?

At the end of the day, I could use some global hook, but I know there are equivalents in similar packages that allow you to catch modifiers.

Any help is appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

悲喜皆因你 2024-10-21 23:27:48

对我有用的是使用 GetMouseState() ,它包含用于修饰符的布尔值。我一直在尝试使用 GetKeyState(),但我需要传入一个关键代码。回想起来,我认为我可以传入任何键,然后检查修饰符,因为这就是我真正想要的。无论如何 - 现在可以了。

def OnDropFiles(self, x, y, filenames):
    mouse = wx.GetMouseState()
    if mouse.CmdDown():
        self.frame.paths += filenames
    else:
        self.frame.paths = filenames
    self.frame.draw_figure()

What worked for me was using GetMouseState() which has booleans for modifiers packed into it. I had been trying to use GetKeyState(), but I needed to pass in a key code. In retrospect, I think I could've passed in any key and then just checked for modifiers since that's what I actually want. Anyhow - it works now.

def OnDropFiles(self, x, y, filenames):
    mouse = wx.GetMouseState()
    if mouse.CmdDown():
        self.frame.paths += filenames
    else:
        self.frame.paths = filenames
    self.frame.draw_figure()
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文