簡體   English   中英

如何復制文本字段實體ursina?

[英]How to copy text field entity ursina?

我創建了一個文本實體,您可以使用ursina中文本實體的TextField版本復制它。 我的代碼是:

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

錯誤

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

知道為什么這是幸福的嗎?

首先, 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

我已經在 GitHub here上提交了一個 pull request,這樣他們就可以修復它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM