Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 7 of 7 total
Thread Why Field Still Highlighted When Focus Is Not On It?
Fri, Feb 9 2018 6:06 PMPermanent Link

Frederick Chin

I have a form with 3 TEdits and 1 TCheckBox.

The first two TEdits are linked to String fields of a DBISAM table while the third is to a BCD field. The TCheckbox field is linked to a Boolean field.

When focus is on the first two fields, the content is highlighted as it should be and not highlighted when they are not focused.

However, the third TEdit field with the BCD content remains highlighted even when focus is not on it.

If you see the attached image, the focus is currently on the TCheckBox but the Price field remains highlighted.

I have two questions:-

1.   How can I remove the highlight of the Price field when focus is lost?

2.   How can I disable highlighting of the Code and Description fields when they are in focus? This is similar to turning off the AutoSelect property in a Delphi program.

--
Frederick



Attachments: price.png
Sat, Feb 10 2018 7:24 AMPermanent Link

Uli Becker

Frederick,

> However, the third TEdit field with the BCD content remains highlighted even when focus is not on it.

It has nothing to do with the content: moving the focus from a TEdit
control to a TCheckbox (or a TButton) shows this behaviour. Maybe a bug,
you should report that as an issue.

> 2.   How can I disable highlighting of the Code and Description fields when they are in focus? This is similar to turning off the AutoSelect property in a Delphi program.

You can put this code in the OnEnter event of the TEdit:

   TEdit(Sender).SelectionStart := Length(TEdit(Sender).Text);

or (if you want the cursor at the left:

   TEdit(Sender).SelectionStart := 0;
   TEdit(Sender).SelectionEnd := 0;

Uli
Sat, Feb 10 2018 9:10 AMPermanent Link

Frederick Chin

Uli,

/*
It has nothing to do with the content: moving the focus from a TEdit
control to a TCheckbox (or a TButton) shows this behaviour. Maybe a bug,
you should report that as an issue.
*/

Do I report this direct to Tim or wait for him to check this message?

/*
You can put this code in the OnEnter event of the TEdit:

   TEdit(Sender).SelectionStart := Length(TEdit(Sender).Text);

or (if you want the cursor at the left:

   TEdit(Sender).SelectionStart := 0;
   TEdit(Sender).SelectionEnd := 0;
*/

Thanks. The above code works great.

--
Frederick
Mon, Feb 12 2018 4:50 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Frederick,

<< However, the third TEdit field with the BCD content remains highlighted even when focus is not on it. >>

This is a bug, but I'm not sure how it can be fixed because it's a product of how the browsers behave with respect to focus and selection ranges for edit controls.  You can't modify the selection range for an edit in a browser without re-focusing the edit control, so EWB uses a kludge whereby it resets the value for the edit control.  This has typically fixed the issue in the past, but obviously it isn't working in certain cases.

This hotfix will work with all browsers except for IE:

procedure TInputElement.SelectNone;
var
  TempSelection: TSelection;
begin
  { Must do it this way to prevent re-focusing the element !!! }
  TempSelection:=window.getSelection;
  if Assigned(TempSelection) then
     TempSelection.removeAllRanges;
end;

so I might just leave it at that for now.  But, in the EWB IDE you will get the wonky behavior because it's using IE under the covers.

Tim Young
Elevate Software
www.elevatesoft.com
Mon, Feb 12 2018 4:55 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com


<< This hotfix will work with all browsers except for IE: >>

Sorry - this hotfix should go in the WebUI unit.

Tim Young
Elevate Software
www.elevatesoft.com
Mon, Feb 12 2018 5:00 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Frederick,

Actually, this hotfix will work for all browsers:

WebUI unit

procedure TInputElement.SelectNone;
var
  TempValue: String;
begin
  { Must do it this way to prevent re-focusing the element !!! }
  TempValue:=THTMLInputElement(DOMElement).Value;
  THTMLInputElement(DOMElement).Value:='';
  THTMLInputElement(DOMElement).Value:=TempValue;
end;

Tim Young
Elevate Software
www.elevatesoft.com
Mon, Feb 12 2018 8:27 PMPermanent Link

Frederick Chin

Tim,

/*
Actually, this hotfix will work for all browsers:

WebUI unit

procedure TInputElement.SelectNone;
var
  TempValue: String;
begin
  { Must do it this way to prevent re-focusing the element !!! }
  TempValue:=THTMLInputElement(DOMElement).Value;
  THTMLInputElement(DOMElement).Value:='';
  THTMLInputElement(DOMElement).Value:=TempValue;
end;
*/

Thanks. This change solves the problem.

--
Frederick
Image