Jump to content
Search Community

delete key deletes multiple selection when in text field

benb test
Moderator Tag

Recommended Posts

I just noticed that if I select more than one text field, then click in one of the text fields to edit it, the text caret blinks as it should, but when I press the delete key, instead of deleting a character, both of the text fields are deleted. Is this a bug or am I missing something? Thanks.

 

Ben

Link to comment
Share on other sites

Thanks for the reply. I could set the allowDelete property to false but that would disable the delete key completely, right? I was just saying that TransformManager shouldn't delete the selected TransformItems if the user is editing a text field and presses the delete key. TransformManager handles this situation correctly when there is only one TransformItem selected (i.e. a character in the text field is deleted), but not when more than one TransformItem is selected. Or are you saying that I should set the allowDelete property to false on each text field's focusIn event and reset it to true on focusOut? Thanks.

 

Ben

Link to comment
Share on other sites

Great. That works well. Thanks. The other thing I just noticed is that with one text field selected (but not focused) the delete key doesn't delete the TransformItem. This is even the case when I remove my new focusIn and focusOut handlers (i.e. allowDelete is always true). Is there a way to get that to work? I'm guessing this code in TransformItem would have to be overridden to delete the item if the text field is not focused.

 

public function onPressDelete($e:Event = null, $allowSelectableTextDelete:Boolean = false):Boolean {
if (_enabled && _allowDelete && (_hasSelectableText == false || $allowSelectableTextDelete)) { //_hasSelectableText typically means it's a TextField in which case users should be able to hit the DELETE key without deleting the whole TextField.
	deleteObject();
	return true;
}
return false;
}

Link to comment
Share on other sites

Yeah, when hasSelectableText is true the assumption is that if the item is selected, any DELETE/BACKSPACE key presses should be interpreted as related to editing the text rather than deleting the item itself. See what I mean? So in your rather unusual case, the best solution is probably to handle deletion manually by listening for the key presses and taking the appropriate action based on whatever parameters you want. Just call deleteObject() on whatever TransformItems you want to delete. You can set allowDelete to false and handle that feature manually.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...