Inject Text in Textarea Input

I am developing a simple perspective expression editor to create and test SQL queries in a perspective session. My editor predicts keywords and provides suggested completion options for a word that has been started. The user can press alt+ctrl to cycle between predicted keywords; when Ctrl is pressed, the keyword is injected into the textarea's text property.

My problem is, when the text is injected, the caret doesn't move to the end, and if I click to the end of the injected word, the caret still doesn't move. Typing also deletes the injected text as if it was never there.

I think you are going to struggle with this as there is limited functionality built into the browser components. A website using these features would program them in Javascript but this is not (generally) an option in Perspective.

We have to caution you about the wisdom (or lack-of) of creating an application like this. You are bypassing all of Ignition's built-in protection of named queries, runPrepUpdate, etc., and if anyone can start your application they can do severe damage to your databases. Using an SQL application such as MySqlWorkbench (for MySQL) would be much safer.

4 Likes