SDL2 在不给予焦点的情况下提升窗口 [英] SDL2 Raising a window without giving it focus

查看:49
本文介绍了SDL2 在不给予焦点的情况下提升窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在窗口上显示工具提示.我正在使用工具提示创建第二个窗口并使用 SDL_RaiseWindow() 将其带到顶部.但是,这样做会导致工具提示窃取焦点,这不是我想要的.有没有办法在不改变焦点的情况下将窗口带到顶部?

I need to display a tooltip over a window. I'm creating a second window with the tool tip and using SDL_RaiseWindow() to bring it to the top. However, doing that causes the tooltip to steal focus which is not what I want. Is there a way to bring a window to the top without changing focus?

另外,有没有办法在不改变窗口的 Z 顺序的情况下设置焦点(鼠标和/或键盘)?

Also, is there a way to set focus (mouse and/or keyboard) without changing the Z order of the windows?

推荐答案

Neil 提供的答案仅适用于 X11,因为 SDL_SetWindowInputFocus() 仅用于实现环境.本质上,否则无法实现所需的行为.我已经看到 SDL 论坛中有一个功能请求,要求重载 SDL_RaiseWindow() 函数以包含一个可选的 bool 参数来指示凸起的窗口是否也应该接收输入焦点.我希望他们确实实现这一点.

The answer offered by Neil will only work under X11 as SDL_SetWindowInputFocus() is only implemented for that environment. In essence, the desired behaviour is otherwise not achievable. I have seen that there is a feature request in the SDL forums for an overload of the SDL_RaiseWindow() function to include an optional bool parameter to indicate if the raised window should also receive the input focus, or not. I hope they do implement that.

无论如何,SDL 2.x 下对多窗口的支持有点弱.没有对不同窗口的 Z 顺序的内置支持,尝试基于画家方法"构建一个有效,但无法控制输入焦点.

In any case, the support for multiple windows under SDL 2.x is a little weak. There is no built in support for the Z-order of different windows, and trying to build one based on the "painter's method" works, but leaves one no control over the input focus.

这篇关于SDL2 在不给予焦点的情况下提升窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆