CodeEdit.get_selected_text() is returning an empty string

Godot Version

4.7

Question

I have a CodeEdit node with the unique name %CodeEdit. I type something into it, select some of the text, and then click a button connected to a function that does this:

var wrapped_text : String = %CodeEdit.get_selected_text()
print(wrapped_text)

But what prints is a blank line. I have also added a 0 to the argument for get_selected_text() with no change in the results. Am I doing something wrong/misunderstanding?

As far as I can tell, CodeEdit does not have a function called get_selected_text

It is inherited from TextEdit.

Also, in the time it took to be accepted, a solution to this particular problem was found:

%CodeEdit.deselect_on_focus_loss_enabled = false

It was deselecting when clicking a button, before it could even get the selected text.