Mwni / pixi-text-input

Plugin for pixi.js which provides a convenient way of adding a text input to the pixijs-stage.
161 stars 44 forks source link

Cursor is placed in wrong place when text is already present in input #17

Open sheerun opened 4 years ago

sheerun commented 4 years ago

Steps to reproduce:

  1. Write some text in input
  2. Place text cursor in the middle of text
  3. Defocus input by clicking outside
  4. Click again on input trying to place text cursors somewhere else

Current behavior:

Text cursor is placed in original location, in the middle

Expected behavior:

Text cursor is placed where mouse cursor clicked

Here's git showing this behavior:

https://giphy.com/gifs/hosFDTCEf9Zhldlf7O

Mwni commented 4 years ago

This is a tricky one. The html input is hidden when substituted. A mousedown on the substituted pixi-text switches the visibility to the html input. however, for the cursor to be set correctly, the input would've had to be visible before that mousedown occured. i'll have check if it's possible to trigger a synthetic copy of that exact mousedown event on the html input, and if that will actually set the cursor position.

sheerun commented 4 years ago

Maybe just show input at all times?

On Fri, Feb 7, 2020 at 3:24 PM Mwni notifications@github.com wrote:

This is a tricky one. The html input is hidden when substituted. A mousedown on the substituted pixi-text switches the visibility to the html input. however, for the cursor to be set correctly, the input would've had to be visible before that mousedown occured. i'll have check if it's possible to trigger a synthetic copy of that exact mousedown event on the html input, and if that will actually set the cursor position.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Mwni/PIXI.TextInput/issues/17?email_source=notifications&email_token=AACHMDIFC2CC3AG26FNMT2DRBVVLPA5CNFSM4KROQNUKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELDCFRI#issuecomment-583410373, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACHMDKABTBOXASPVRJZZXDRBVVLPANCNFSM4KROQNUA .

Mwni commented 4 years ago

Well if that's an option for you. Set input.substituteText = false Keep in mind placing things above it will not be possible with that setting.