Inject Text into WTextArea (Wt 3.11)

Added by Charles Hubbard 4 months ago

Is it possible, from my own code, to insert text at the current cursor position inside a WTextArea widget? I would like to bind a key that, when pressed, inserts the current date/time at the WTextArea cursor position, but I can not figure out a way to do that. My best kludge has been to retrieve the current text from the widget into a std::string, insert my text at the current cursor position offset in that string, and then reload the contents of the widget with the result. It works, but it's ugly, and it leaves the cursor at the very bottom of the WTextArea. I would rather the cursor be at the end of the text I just added. Is there some way to initiate a "paste" action from my code or something like that? "paste" behavior is exactly what I'm looking for. I just don't know how to do it.