Subject | Re: [IBO] Problem with IB_LocateEditEnh |
---|---|
Author | Geoff Worboys |
Post date | 2001-01-14T04:16:11Z |
> Go for it Geoff. Sounds like some worthy enhancements. As IJason,
> recall now, someone did make those changes and sent them to me.
I have a small problem. I setup a property on the LocateEdit called
"DisableEditing". I wanted to use this to prevent the user from
trying to change the contents of the locate edit while in one of the
edit modes.
I started by looking at what you had in IBC_CustomEdit.IMP - where you
change the control ReadOnly status in the EditingChanged handler. So
I setup the following in LocateEdit...
procedure TIB_LocateEdit.EditingChanged( Sender: TIB_DataLink;
IB_DataSource:
TIB_DataSource );
begin
if (DataLink.State in [dssInsert,dssEdit,dssSearch]) then begin
if DisableEditing then
inherited ReadOnly := true
else inherited EditingChanged( Sender, IB_DataSource );
end;
end;
This did not have the desired effect, a user could still type
characters into the control.
I did come up with a fix, but I need you to verify that this should be
safe. In IBC_Edit.IMP I looked for calls to EditCanModify in the key
stroke handlers.
From KeyDown I setup as...
end else begin
inherited KeyDown( Key, Shift );
if ( Key = VK_DELETE ) or
(( Key = VK_INSERT ) and ( ssShift in Shift )) then begin
if not EditCanModify then
Key := 0; // prevent the change <<< === See this
From KeyPress I setup as...
case Key of
^H, ^V, ^X, #32..#255: begin
if EditCanModify then begin
if ( Length( Text ) = 0 ) and
( Field <> nil) and
( FieldCharCase = ccProper ) then begin
Key := AnsiUpperCase( Key )[1];
end;
end else Key := #0; // dont allow change <<< === See this
end;
All I am doing in each case is preventing further processing of the
key by setting it to zero when EditCanModify returns false. AFAICT
this **should** always be safe, however since TIB_Edit is such a
central control I thought I should ask your opinion.
Note: I would have sent you the entire unit, but it also contains
AutoLabel changes at this stage.
TIA
Geoff Worboys
Telesis Computing