No new rveTable-row by pressing TAB in last rveTable-cell
Posted: Wed Aug 12, 2009 6:56 am
Hello,
my aim is that someone can't expand a new table-row by pressing TAB in the last rveTable-cell.
My trials show that program doesn't run through memoKeyDown or memoKeyPress (look at
//<-------------------------------------).
Has someone an idea?
procedure TForm1.memoKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
var Cell: TRVTableCellData;
Table: TRVTableItemInfo;
r,c: integer;
begin
if memo.InplaceEditor=nil then begin //Schreibmarke ist im Memo
if storedRveTabNo<1 then begin
if key>0 then begin
key:= vk_left; RVSetLinearCaretPos(memo,0);
exit;
end;
end;
end else begin //Schreibmarke befindet sich in der Memo-Tabelle
if (ssShift in Shift) and (key=vk_return) then begin
Shift:= []; key:= vk_left;
end else if (ssCtrl in Shift) then begin
if (key=vk_return) then begin
Shift:= []; key:= VK_Right;
end else if (key=vk_down) then begin
table1.next; exit;
end else if (key=vk_up) then begin
table1.prior;
exit;
end else if (key=vk_end) then begin
Shift:= []; key:= vk_left;
exit;
end else if (key=vk_home) then begin
Shift:= []; key:= vk_right;
exit;
end;
end else if (key=vk_return) then key:= VK_Right;
Cell := TRVTableInplaceEdit(memo.InplaceEditor).FCell;
Table := Cell.GetTable;
r := TRVTableInplaceEdit(memo.InplaceEditor).FRow;
c := TRVTableInplaceEdit(memo.InplaceEditor).FCol;
if ((Key=VK_UP) and (r=0) and IsInFirstLine(memo.TopLevelEditor)) or
((Key=VK_DOWN) and (r=Table.RowCount-1) and IsInLastLine(memo.TopLevelEditor)) or
((Key=VK_Left) and (c=0) and IsAtTheBeginning(memo.TopLevelEditor)) or
((Key=VK_Right) and (c=Table.ColCount-1) and IsAtTheEnd(memo.TopLevelEditor)) or
((Key=VK_TAB) and (c=Table.ColCount-1) and IsAtTheEnd(memo.TopLevelEditor)) then key:= 0; //<-------------------------------------
end; //of Schreibmarke befindet sich in der Memo-Tabelle
end;
procedure TForm1.memoKeyPress(Sender: TObject; var Key: Char);
var i, tableNo,zei: integer;
begin
if memo.InplaceEditor=nil then begin //Schreibmarke ist im Memo
if ord(key)>0 then begin
key:= #0;
//key:= vk_left;
RVSetLinearCaretPos(memo,0);
for i := 0 to Memo.ItemCount-1 do begin
if Memo.GetItemStyle(i)=rvsTable then begin
inc(tableNo);
if tableNo=storedRveTabNo then begin
rveTable := TRVTableItemInfo(memo.GetItem(i));
rveTable.EditCell(0,1);
break;
end;
end;
end;
end;
end else begin
if ord(key)= 9 then key:= #0; //<-------------------------------------
end;
end;
my aim is that someone can't expand a new table-row by pressing TAB in the last rveTable-cell.
My trials show that program doesn't run through memoKeyDown or memoKeyPress (look at
//<-------------------------------------).
Has someone an idea?
procedure TForm1.memoKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
var Cell: TRVTableCellData;
Table: TRVTableItemInfo;
r,c: integer;
begin
if memo.InplaceEditor=nil then begin //Schreibmarke ist im Memo
if storedRveTabNo<1 then begin
if key>0 then begin
key:= vk_left; RVSetLinearCaretPos(memo,0);
exit;
end;
end;
end else begin //Schreibmarke befindet sich in der Memo-Tabelle
if (ssShift in Shift) and (key=vk_return) then begin
Shift:= []; key:= vk_left;
end else if (ssCtrl in Shift) then begin
if (key=vk_return) then begin
Shift:= []; key:= VK_Right;
end else if (key=vk_down) then begin
table1.next; exit;
end else if (key=vk_up) then begin
table1.prior;
exit;
end else if (key=vk_end) then begin
Shift:= []; key:= vk_left;
exit;
end else if (key=vk_home) then begin
Shift:= []; key:= vk_right;
exit;
end;
end else if (key=vk_return) then key:= VK_Right;
Cell := TRVTableInplaceEdit(memo.InplaceEditor).FCell;
Table := Cell.GetTable;
r := TRVTableInplaceEdit(memo.InplaceEditor).FRow;
c := TRVTableInplaceEdit(memo.InplaceEditor).FCol;
if ((Key=VK_UP) and (r=0) and IsInFirstLine(memo.TopLevelEditor)) or
((Key=VK_DOWN) and (r=Table.RowCount-1) and IsInLastLine(memo.TopLevelEditor)) or
((Key=VK_Left) and (c=0) and IsAtTheBeginning(memo.TopLevelEditor)) or
((Key=VK_Right) and (c=Table.ColCount-1) and IsAtTheEnd(memo.TopLevelEditor)) or
((Key=VK_TAB) and (c=Table.ColCount-1) and IsAtTheEnd(memo.TopLevelEditor)) then key:= 0; //<-------------------------------------
end; //of Schreibmarke befindet sich in der Memo-Tabelle
end;
procedure TForm1.memoKeyPress(Sender: TObject; var Key: Char);
var i, tableNo,zei: integer;
begin
if memo.InplaceEditor=nil then begin //Schreibmarke ist im Memo
if ord(key)>0 then begin
key:= #0;
//key:= vk_left;
RVSetLinearCaretPos(memo,0);
for i := 0 to Memo.ItemCount-1 do begin
if Memo.GetItemStyle(i)=rvsTable then begin
inc(tableNo);
if tableNo=storedRveTabNo then begin
rveTable := TRVTableItemInfo(memo.GetItem(i));
rveTable.EditCell(0,1);
break;
end;
end;
end;
end;
end else begin
if ord(key)= 9 then key:= #0; //<-------------------------------------
end;
end;