Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 6 of 6 total
Thread TEdit.SelectAll
Thu, Nov 16 2017 5:30 AMPermanent Link

Matthew Jones

Just a thought on this, but I get the impression that this doesn't work if you set the content and then call it. I suspect this is because the DOM hasn't been updated yet, and so there is nothing to select, or it gets cleared. But I have an OnEnter which changes the text (when not in, it shows values with things like currency or percent signs, when editing, it removes them and goes full precision) and SelectAll doesn't work. But doing edit.SelectStart := 0; edit.SelectEnd := Length(myContent); works fine.

--

Matthew Jones
Thu, Nov 16 2017 1:09 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Matthew,

<< Just a thought on this, but I get the impression that this doesn't work if you set the content and then call it. I suspect this is because the DOM hasn't been updated yet, and so there is nothing to select, or it gets cleared. But I have an OnEnter which changes the text (when not in, it shows values with things like currency or percent signs, when editing, it removes them and goes full precision) and SelectAll doesn't work. But doing edit.SelectStart := 0; edit.SelectEnd := Length(myContent); works fine. >>

SelectAll does exactly that:

procedure TInputElement.SelectAll;
begin
  if (Self=InterfaceManager.ActiveElement) then
     THTMLInputElement(DOMElement).setSelectionRange(0,Length(InputValue));
end;

However, you'll notice that it does a check on the focused element first.  That may be what is tripping you up, but I would have to investigate this further to be sure.

Tim Young
Elevate Software
www.elevatesoft.com
Fri, Nov 17 2017 3:32 AMPermanent Link

Matthew Jones

Tim Young [Elevate Software] wrote:

> SelectAll does exactly that:

Hah! I didn't click the further call when I chased it down as I presumed it was a "native DOM" thing. I suspect that you are right in the focus issue - OnEnter may not know it is the new focus I guess.
Is there a reason it can't select all for anything? Why can't I selectAll in a hundred edits at the same time?

--

Matthew Jones
Tue, Nov 21 2017 1:21 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Matthew,

<< Hah! I didn't click the further call when I chased it down as I presumed it was a "native DOM" thing. I suspect that you are right in the focus issue - OnEnter may not know it is the new focus I guess.
Is there a reason it can't select all for anything? Why can't I selectAll in a hundred edits at the same time? >>

It actually *is* a native DOM thing - an input element must have focus before you can manipulate the selection ranges for the input element.

Tim Young
Elevate Software
www.elevatesoft.com
Mon, Nov 27 2017 1:25 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Matthew,

<< Just a thought on this, but I get the impression that this doesn't work if you set the content and then call it. I suspect this is because the DOM hasn't been updated yet, and so there is nothing to select, or it gets cleared. But I have an OnEnter which changes the text (when not in, it shows values with things like currency or percent signs, when editing, it removes them and goes full precision) and SelectAll doesn't work. But doing edit.SelectStart := 0; edit.SelectEnd := Length(myContent); works fine. >>

I can't reproduce what you're seeing here.  I'm doing this:

procedure TForm1.Edit1Enter(Sender: TObject);
begin
  Edit1.Text:='Hello World';
  Edit1.SelectAll;
end;

and it works fine, selecting all of the text.

If you want to send me something more specific, I can test it out here and see what's going on.

Tim Young
Elevate Software
www.elevatesoft.com
Tue, Nov 28 2017 4:23 AMPermanent Link

Matthew Jones

Tim Young [Elevate Software] wrote:

> I can't reproduce what you're seeing here.

Hmm, okay, I will dig into it further.

--

Matthew Jones
Image