:arrow: Here You are, as requested; the dev platform currently is win32, Lazarus version is of 10th dec 2004 (the latest I presume); I've not yet tested this code in Linux-GTK;
(commented code portions follows):
procedure TCruci.thegridKeyPress(Sender: TObject; var Key: char);
var
x: LongInt;
y: LongInt;
c: char;
begin
if key in ['a'..'z', 'A'..'Z'] then begin
c:=upcase(key);
x:=thegrid.col;
y:=thegrid.row;
if thegrid.cells[x,y] = '' then begin
thegrid.cells[x,y]:=c;
Here the char is inserted in the appropriate cell on the grid, and the cell gfx switch to selected (negative) ...
... (if conditionals)
repeat begin
if x < 14 then thegrid.col+=1
else thegrid.col:=0
end
until (thegrid.cells[thegrid.col,y] = '') or (thegrid.col <> x);
... (else conditional)
... and here the cursor (red dotted square) is not updated on the grid during the loop, nor at the end, and the cell[x,y] (i.e. the first cell that originates the event) is always in selected gfx ...
... (previous conditionals)
else if key = chr(08) then begin // the backspace key (I know use of chr(ascii-code) it's deprecated, and I should use defined constants VK_*, but I'm only in an early debug stage and that will be fixed :? )
if thegrid.col>0 then thegrid.col-=1
else thegrid.col:=15;
if thegrid.cells[thegrid.col, thegrid.row]<>'' then begin
thegrid.cells[thegrid.col, thegrid.row]:='';
p1p-=1;
end
... this leaves the grid cursor (the red dotted square) drawed in the cell that generated the event ...
thegrid.refresh()
end;
... this is the end of the procedure, but the .refresh() call does not seem to work.
I'm unable to post a screenshot (I don't know how to insert an image in this post), but seems that losing focus (the form) clears the bad red squares, leaving the "selected" cells in negative gfx ...
I've looked for the TStringGrid control source code, but found nothing wrong :!:
Thanks in advance for anyone who knows how to fix.
[/img]