Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 14 total
Thread TEdit UPPERCASE data entry
Thu, Aug 6 2015 8:30 PMPermanent Link

Trinione

Hi:
How can data be captured in UPPERCASE using the TEdit component?

I am trying to use the KeyPress event with no success.

function TfrmMain.edtLastNameKeyPress(Sender: TObject; Key: Char; ShiftKey, CtrlKey, AltKey: Boolean): Boolean;
begin
 Key := UpperCase(Key)[1];
 result := true;
end;
Thu, Aug 6 2015 9:19 PMPermanent Link

Trinione

That should have been:

begin
 Key := UpperCase(Key);
 result := true;
end;
Fri, Aug 7 2015 1:49 AMPermanent Link

Michael Dreher

Trinione wrote:
  //  Hi:
  //  How can data be captured in UPPERCASE using the TEdit component?
  //  
  //  I am trying to use the KeyPress event with no success.
  //  
  //  function TfrmMain.edtLastNameKeyPress(Sender: TObject; Key: Char; ShiftKey, CtrlKey,
  //  AltKey: Boolean):    //  Boolean;
  //  begin
  //    Key := UpperCase(Key)[1];
  //    result := true;
  //  end;

The reason must be, that "Key" has local scope to the event handler function (call by value semantics). In contrast to the Delphi pascal TEdit::OnKeyPress handler, Key is call by reference parameter (var key :char).

I suggest using the OnExit handler like this:

procedure TForm1.edLastNameExit(Sender: TObject);
begin
 edLastName.Text := UpperCase(edLastName.Text);
end;

You'll get (and it's displayed) the uppercase value, but not every key stroke.

Michael Dreher
Fri, Aug 7 2015 6:52 AMPermanent Link

Walter Matte

Tactical Business Corporation


In the OnChange Event:


 Edit1.Text := Uppdate(Edit1.Text);


This will show for every keystroke.

Walter
Fri, Aug 7 2015 6:53 AMPermanent Link

Walter Matte

Tactical Business Corporation

Walter Matte wrote:


In the OnChange Event:


 Edit1.Text := Uppercase(Edit1.Text);


This will show for every keystroke.

Walter
Fri, Aug 7 2015 7:56 AMPermanent Link

Malcolm Taylor

I am using both OnChange and OnExit (not together) but I am aiming
mostly at mobile devices so have to deal with the virtual keyboard.

What I am missing is a convenient 'Done' key.
I see that using InputType=tiNumber gives me a working Tab key which
allows me to move from one TEdit to the next one.
But I can't see how to get that working for the other ti* elements -
the green button tap gets swallowed somewhere so maybe I am missing
some property setting.  Surprised

I have tried a number of things with little luck.  So far as the upper
case question is concerned, I did try to use OnKeyDown to set ShiftKey
= True but I could not get that to work.
Fri, Aug 7 2015 10:25 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

<< How can data be captured in UPPERCASE using the TEdit component? >>

OnKeyPress has a serious bug in it that will be fixed in 2.01:

http://www.elevatesoft.com/forums?action=view&category=ewb&id=ewb_general&page=1&msg=6260#6260

Tim Young
Elevate Software
www.elevatesoft.com
Fri, Aug 7 2015 10:27 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

However, as Michael points out - you can't do what you're trying to do.  The browser does not let you modify keystrokes "in-place" like Windows.

Tim Young
Elevate Software
www.elevatesoft.com
Fri, Aug 7 2015 1:56 PMPermanent Link

Trinione

Thanks all. I would use the OnChange event to effect the uppercase.

Tim:
Could this be a future TEdit Property (Version 2.04) ? It would be easier to set a property on a field like this rather than having to do it by code.
Fri, Aug 7 2015 2:04 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Trinione wrote:

<< Could this be a future TEdit Property (Version 2.04) ? It would be easier to set a property on a field like this rather than having to do it by code. >>

Yeah, I'll probably add some formatting to the inputs when I deal with some of the TDataSet limitations.

Tim Young
Elevate Software
www.elevatesoft.com
Page 1 of 2Next Page »
Jump to Page:  1 2
Image