c - 你如何在SDL2中设置光标位置?

标签 c window sdl sdl-2

我希望能够在我的 SDL2 窗口上更改光标的位置。我在文档中找不到任何内容。有没有办法做到这一点?

最佳答案

使用 SDL_WarpMouseInWindow()函数,它设置鼠标在 SDL 窗口中的位置。
示范:

auto* WIN = SDL_CreateWindow("text", 0, 0, Width, Height, SDL_WINDOW_RESIZABLE);
SDL_WarpMouseInWindow(WIN, 50, 50);/*sets mouse position to 50, 50 relative to the window */
请记住,这会调用 SDL_MOUSEMOTION因此,如果您正在轮询事件,它会将鼠标位置的变化视为鼠标移动。
这是一个引用:https://wiki.libsdl.org/SDL_WarpMouseInWindow

关于c - 你如何在SDL2中设置光标位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32282499/

相关文章:

c - Fscanf 和字符串

c++ - 打印文件的创建时间为什么是+7 :00 hours ahead of the actual file creation time?

C程序跳过fgets

python - 使用 selenium 在 python 中处理多个选项卡时出现 IndexError

c++ - Windows下获取当前窗口位置

wpf - 没有在 DLL 项目中创建 WPF 窗口?

c++ - 将 Uint8 转换为 unsigned char RGB 值

无法使用 SDL_gfxPrimitive

执行线程时更改C线程参数

c++ - 丢失指针值