Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TEXTBOX] Problems with characters selection using mouse inside the textbox #2494

Closed
alanmastro opened this issue Sep 23, 2015 · 12 comments · Fixed by #2503
Closed

[TEXTBOX] Problems with characters selection using mouse inside the textbox #2494

alanmastro opened this issue Sep 23, 2015 · 12 comments · Fixed by #2503
Assignees
Labels

Comments

@alanmastro
Copy link

I compiled fabricjs using the latest sources present in the repo with this command:

node build.js modules=ALL minifier=uglifyjs

but when I try to select the text in the textbox with the mouse the textbox loses focus.
I created a jsfiddle to reproduce the problem:

http://jsfiddle.net/n3k9xrag/

the compiled version of fabricjs is hosted in one of our servers.

@asturur
Copy link
Member

asturur commented Sep 23, 2015

I will check this asap.

@asturur asturur added the text label Sep 24, 2015
@asturur asturur self-assigned this Sep 24, 2015
@glashtin
Copy link

has to do with canvas.class.js _checkTarget class.

removing line 926 seems to fix the problem but guessing it is just not getting set and should be set elsewhere.

obj.selectable &&

@asturur
Copy link
Member

asturur commented Sep 24, 2015

I do not kwow.
First thing i did when i spotted thid bug, i made a console.log of obj.selectable BEFORE and AFTER clicking the text inside. And it was always true.
That recent change was the first guilty commit i went to check, but i excluded it after this test.

To you it solves?

@alanmastro
Copy link
Author

@glashtin I tried your solution and it seems to work, but I don't know how this could create problems elsewhere. I'll do some more tests to check that everything works.

@asturur
Copy link
Member

asturur commented Sep 25, 2015

that line was recently added to close an issue about selecting object marked as not selectable.

this means that we have to see why the itext is marked as not selectable when it is editing mode.

@alanmastro
Copy link
Author

I think the problem is here:

_setEditingProps: function() {
      this.hoverCursor = 'text';

      if (this.canvas) {
        this.canvas.defaultCursor = this.canvas.moveCursor = 'text';
      }

      this.borderColor = this.editingBorderColor;

      this.hasControls = this.selectable = false;
      this.lockMovementX = this.lockMovementY = true;
    }

@asturur
Copy link
Member

asturur commented Sep 27, 2015

i see two ways of solve this:

  1. adding
    (obj.selectable || obj.isEditing ) &&
    so we include an already clicked itext that has selectable = false.

  2. investigate why is possible to selected a not selectable obect if sorrounded by selectable objects, solve that and remove this obj.selectable addition in _checkTarget.

see #2460

  1. i forgot: remove this.selectable = false from Itext. that does not look like add strange unwanted effects.

@asturur
Copy link
Member

asturur commented Sep 27, 2015

ok adding obj.selectable in _checkTarget was an error.
_checkTarget is a generic function to find the target. If one object is not selectable it does not mean it cannot be chosen as a target. Just is not possible to select it.

So reverting that change and fix #2460 in proper way is better.

@parmesh1234
Copy link

i am still facing the same issue was anyone able to track it down or find a work around.
i tried to make selectable to false when the pointer is in the textbox in mouse down event but it is not working properly.

@asturur
Copy link
Member

asturur commented Nov 16, 2018

On what version of fabric are you working and what are you trying to obtain?
Please create a fiddle with your code and link it here., if is unrelated we can open a new issue

@parmesh1234
Copy link

Hi asturur,

We are not using Textbox directly, based on our project scenario we are connecting the Textbox and Rectangle with Line so when i checked the Textbox selectable key value it is true, with selectable true i am not able to make a text selection in Textbox if i make the selectable value to false, i am able to select text in Textbox using mouse but the connection between the Rectangle and Textbox goes off.

currently i am not able to provide the fiddle for this issue, can you please tell me how can i select text without loosing the connection between the Textbox and Rectangle.

Thanks
Parmeshwar

@asturur
Copy link
Member

asturur commented Dec 8, 2018

normally to select text programmatically you can enter in editing mode and use setSelectionStart and setSelectionEnd to set the index where the selection start and finish.

Currently there is no way to draw text selection outside editing mode

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants