Author Topic: UIInput textbox unwanted behavior  (Read 3239 times)

sandiegosandiego213

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
UIInput textbox unwanted behavior
« on: February 17, 2015, 03:18:27 AM »
Hi there! I'm currently using the UIInput widget as a text box. However, when the mouse is clicked inside the UIInput to get focus, the caret always appears at the end of the text inside the text box. How can I get the caret to appear close to where the mouse was actually clicked? Any options or workarounds, as this is very important to my project.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIInput textbox unwanted behavior
« Reply #1 on: February 17, 2015, 09:39:06 PM »
Press it again with the input field selected and it will do just that -- the cursor will move, the text won't be selected anymore. Try it in your browser: click on the address field above. See how it selects the whole thing? Now click again.

If you want it to not select anything and simply position the cursor, have a look inside UIInput's Update() function, around line 590. Selection start and end are chosen there. Now examine UIInput's OnPress() function and note how if it's already selected, it will set both selectionStart and selectionEnd to GetCharUnderMouse().