Subject RE: [IBO] IB_Grid and Enhanced controls
Author Jason Wharton
I've added this to my items to try and resolve in a future sub-release ASAP.

Jason Wharton
www.ibobjects.com

> -----Original Message-----
> From: dmarmur2002 [mailto:arbit@...]
> Sent: Tuesday, January 18, 2005 12:23 AM
> To: IBObjects@yahoogroups.com
> Subject: Re: [IBO] IB_Grid and Enhanced controls
>
> --- In IBObjects@yahoogroups.com, Geoff Worboys <geoff@t...> wrote:
> > 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.
>
> This corrects the problem, but it also breaks another fix that Jason
> put into 4.5. When you tab into an empty grid the app will not show
> where the focus is at. This is not good UI and unacceptable for some
> impared users. I suppose it will also creates problems with
> screenreading software, (but that project has not started for
> real yet).
>
> That is <probably> why Jason put the code in. Tab into an empty grid
> where there's embedded controls. Without the comment you will
> immidiately see where the focus went. With the comment (or version
> 4.3) the focus seems to dissapear until you press Alt.
>
> > 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).
>
> I did not know that but I often wondered what the use was with
> embedding TIB_Edits.
>
> >
> > 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.
> >
>
> See above :)
>
> /Dany