简体   繁体   English

如何在 PyGame 中将光标设置到文本行

[英]How to set the cursor to the text line in PyGame

I am working on a PyGame Project, and currently working on the inputboxes.我正在从事 PyGame 项目,目前正在研究输入框。 Now, if the cursor is hovering over the inputbox, i need it to change to the text cursor.现在,如果光标悬停在输入框上,我需要将其更改为文本光标。 The one you see when editing a.txt file.您在编辑 a.txt 文件时看到的那个。 Right now, i am using pygame.set_cursor, but that doesn't semm to have the option that i want.现在,我正在使用 pygame.set_cursor,但它并没有提供我想要的选项。 Does anyone know how to do that?有谁知道这是怎么做到的吗? Thanks!谢谢!

The following, which is copied straight from pygame.org docs, works fine for me:以下内容直接从 pygame.org 文档复制而来,对我来说效果很好:

cursor = pygame.cursors.compile(pygame.cursors.textmarker_strings)
pygame.mouse.set_cursor((8, 16), (0, 0), *cursor)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM