I see
TextFieldControl.setCursorPosition(int);
but I don’t see .getCursorPosition()
for some reason. The closest thing I found was TextFieldLogic
, which wasn’t publicly exposed. I tried this
TextFieldControl input = GetChatInput_old(); //gets the textfield of an instance of the chatbox control String old_text = input.getText(); //starting text TextFieldLogic logic = new TextFieldLogic(old_text, new ClipboardAWT(), input); //can't figure out how to extract, so making a new one logic.put(); // I saw someone doing this, so I tried it. System.out.println( logic.getSelectionStart()+" | " + logic.getSelectionLength()+" | " + logic.getSelectionEnd()+" | "+ logic.getCursorPosition() + " | "+ logic.getDisplayedText().toString() );
This outputs -1 | 0 | -1 | {integer representing the length of the current contents of the clipboard} | {the contents of the clipboard followed by the contents of the textfield}
If I remove the logic.put();
line, it’s always -1 | 0 | -1 | 0 | {current contents of the textfield}
The eventual goal (in addition to manipulating the cursor) is a textbox with emoticon substitution like :fire_element:
being replaced with in the chat box. When the is copied and pasted out of textbox, it should be pasted as the string :fire_element:
again. I’d rather not recreate the redraw function and all the clicking and highlighting functions.
I notice TextFieldControl
is deprecated, but I didn’t see an alternative and it’s used in the included ChatControl
. Considering my goals, what’s the best way to do this?