Irrlicht Gui 鼠标无法单击按钮

发布于 2024-12-25 12:42:02 字数 643 浏览 1 评论 0原文

我正在 Irrlicht (C++) 中制作我的第一个游戏,这是一个带有鼠标控制的 RTS

,当您选择一个图块(通过单击它)时,它会亮起,屏幕上会出现一些 gui 按钮(请注意,不是在 gui 窗口中,我喜欢这样):

http://i1139.photobucket.com/albums/n549/Adam_Halley-Prinable/Untitled2.png

但是,由于我切换到鼠标控制,按钮不会记录我的鼠标点击。单击直接穿过按钮并选择后面的图块:

http:// /i1139.photobucket.com/albums/n549/Adam_Halley-Prinable/Untitled3.png

有办法吗我可以说“按钮获得点击的最高优先级”吗? 我正在使用 MyEventReceiver,我用它来接受鼠标点击等等。

非常感谢:D

I'm making my first game in Irrlicht (C++), an RTS with mouse control

and when you select a tile (by clicking on it) it lights up and some gui button appear on the screen (not in a gui window mind you, I like it this way):

http://i1139.photobucket.com/albums/n549/Adam_Halley-Prinable/Untitled2.png

However, since i switched to mouse control, the buttons wont register my mouse clicks. The click goes straight through the button and selects the tile behind instead:

http://i1139.photobucket.com/albums/n549/Adam_Halley-Prinable/Untitled3.png

Is there a way I can say "Buttons get top priority for clicks"?
I'm using MyEventReceiver, which i've messed around with to accept mouse clicks and that.

Thanks a bunch :D

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

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

发布评论

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

评论(2

不疑不惑不回忆 2025-01-01 12:42:02

如果其他人也有同样的问题,我会告诉你我是如何解决的:)

浏览 MyEventReceiver.h 并删除鼠标部分中的所有“return true;”。

不要问我为什么,但它确实有效,而且似乎没有副作用。确保保留“return false;”在该部分的末尾。

If anyone else has the same problem, ill tell you how I solved it :)

Go through the MyEventReceiver.h and get rid of all the "return true;"'s in the mouse section.

Don't ask me why, but it works, and appears to have no side effects. Make sure you leave the "return false;" at the end of the section there.

听风吹 2025-01-01 12:42:02

您的事件接收器在 GUI 访问事件之前触发,如果您想将其传递给 GUI,则可以通过手动将其发布到事件接收器中的 GUIEnvironment 来完成此操作。

if (guienv->postEventFromUser(event)) 
    return true; // abort because the gui wanted it

// .. pick nodes

// possibly post event to scene manager

return true; // remember to return true so gui/smgr don't get the event again

Your event receiver fires before the GUI gets access to the event, if you want to pass it to the GUI then you can do this by manually posting it to the GUIEnvironment in your event receiver.

if (guienv->postEventFromUser(event)) 
    return true; // abort because the gui wanted it

// .. pick nodes

// possibly post event to scene manager

return true; // remember to return true so gui/smgr don't get the event again
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文