简体   繁体   English

如何复制文本字段实体ursina?

[英]How to copy text field entity ursina?

I created a text entity that you can copy using the TextField version of the text entity in ursina .我创建了一个文本实体,您可以使用ursina中文本实体的TextField版本复制它。 my code was:我的代码是:

test = TextField(max_lines=100, scale=3, register_mouse_input = False, text='1234')

The error :错误

NameError: name 'selectedText' is not defined. Did you mean: 'selected_text'?

any idea why this is happining?知道为什么这是幸福的吗?

Firstly, the register_mouse_input parameter should be True , now the Actual fault is in text_field.py , You can find it in the ursina/prefabs folder, the get_selected function sould return selected_text not selectedText , the function's code should be:首先, register_mouse_input参数应该是True ,现在实际错误在text_field.py ,你可以在ursina/prefabs文件夹中找到它, get_selected function 应该返回selected_text而不是selectedText ,函数的代码应该是:

def get_selected(self):
    if not self.selection or self.selection[0] == self.selection[1]:
        return None

    sel = self._ordered_selection()
    start_y = int(sel[0][1])
    end_y = int(sel[1][1])
    lines = self.text.split('\n')

    selected_text = ''
    # selected_text = lines[start_y][]

    for y in range(start_y, end_y+1):
        if y > start_y:
            selected_text += '\n'
        selected_text += lines[y][(int(sel[0][0]) if y == start_y else 0) : (int(sel[1][0]) if y == end_y else len(lines[y])) ]

    return selected_text

I have submitted a pull request on GitHub here , so that they can fix it.我已经在 GitHub here上提交了一个 pull request,这样他们就可以修复它。

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

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