Subject Re: [IBO] IB_Grid and Enhanced controls
Author Geoff Worboys
Hi Dany,

> Since 4.5Ai I have a strange problem. If a grid does not
> currently have focus and I click on the grid the current
> row (correct column) gets the editor.

In your ib_grids.pas unit find:

procedure TIB_CustomGrid.CMEnter( var Message: TCMEnter );
var
AGridCoord: TGridCoord;
begin
inherited;
// It seems a pity to call this on every entry, its only needed
// on the first time after the lookup dataset has been prepared.
// Without this the tabstop may not have been initialised properly.
UpdateColumnAttributes;

// When freshly entering the grid the focused cell is likely not properly
// initialized. Especially with the use of embedded controls.
FFocusedCell.X := -1;
FFocusedCell.Y := -1;

AGridCoord.X := Col;
AGridCoord.Y := Row;
SetFocusedCell( AGridCoord );
//?? if not PositionControl( Col, Row, CellRect( Col, Row )) then
//?? SysUpdateEditor;
end;


In the above you will see where I have commented out '//??' the
last two lines - removing the PositionControl and SysUpdateEditor
calls. This seems to solve the problem.

Please note: TIB_Edit (the non Enh editor) is not really designed
to be dropped onto a grid (it does not implement the grid interface
needed to behave consistently) - because it has much the same
features as the inplace editor. TIB_ComboBox (the non Enh combo) is
designed to be dropped onto TIB_Grid and it would have experienced
the same problems as you saw with TIB_EditEnh (and all other
Enh controls).


Jason,

The problem is that in TIB_CustomGrid.MouseDown one of the first
things to happen is a call to AcquireFocus. Note that this
happens BEFORE the Col and Row values are to the position of the
click. AcquireFocus results in a call to .CMEnter (as shown
above), in which case the grid editor (either the dropped one
if PositionControl works, or the InplaceEditor if SysUpdateEditor
is called) is shown at the OLD col and row position. As a result
of being shown the editor receives focus - removing focus from
the Grid itself and making AcquireFocus return false.

So I am not sure exactly why you added these lines in v4.5, but
they are causing problems and need to be reviewed.

--
Geoff Worboys
Telesis Computing