I just saw you marked it as resolved. Was going to get back to you and it slipped my mind… Bugger.
Ya,for example when you open a notepad
after some typing some text the cursor
will be at the beginning. I wanna
implement similar to that(if i type
something and close it and then open
the same the cursor should be at the
beginning of the first line).
Does it automatically appear in the second line?
I think this might be a limitation of the UMG at the point; as in, you may not have direct control over the position of the caret. A couple of things you could try:
- figure out why the cursor goes to the second line in the first place - user action or automatic. If it’s user action, there might be a way to catch that action and override it (like you did with enter). If it automatically goes to the second line, perhaps the onPreviewKey is not passing
Handled
/Unhandled
correctly. - clean up the text - convert to string, trim trailing spaces, put the trimmed text back in the box
- manually set focus to the widget when opening the page; in theory, this should place the cursor at the beginning / end of the text line, rather than in a new one
- unlikely, but perhaps the cursor going to the second line is the result of text wrapping?
Judging by your description, I’d say there is an issue with passing Handled
/ Unhandled
- could you show a screenshot of that? Somehow I feel that the box still processes that key. But please do correct me if I’m mistaken.
the cursor should be at the
beginning of the first line
I’m not getting why you’d want that, shouldn’t it be at the end of the line - so the user can continue typing where they left off? Or is this a conscious design choice, which is, of course, understandable.