0

I created a text entity that you can copy using the TextField version of the text entity in ursina . 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?

Tanay
  • 561
  • 1
  • 3
  • 16

1 Answers1

1

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:

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.

Tanay
  • 561
  • 1
  • 3
  • 16
  • @Alex Krakowiak, As the pull request was merged, now you can implement it directly without making any edits, You just need to execute this command to update the ursina package : `pip install https://github.com/pokepetter/ursina/archive/master.zip --upgrade --force-reinstall` – Tanay Jan 23 '23 at 13:00