how to enable edit in party area?
-
- Posts: 38
- Joined: Sat Nov 06, 2010 5:12 am
how to enable edit in party area?
I uses richviewedit with table , enable user can edit in cell but user cannt edit out side table cell . how to ?
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Posts: 38
- Joined: Sat Nov 06, 2010 5:12 am
Sergey , Thanks your help.
I mean User can edit content the table ,but can't edit, insert content in out of table.
I use OnKeyPress and OnPaste of RichViewEdit. and use a varible
but the caret is at before table or after table only (on same line) , those does'nt work.
How to detect the caret position only before or after a table?
I mean User can edit content the table ,but can't edit, insert content in out of table.
I use OnKeyPress and OnPaste of RichViewEdit. and use a varible
Code: Select all
var
FCurrInTable :Boolean;
procedure TfrmAppMain.rveKeyPress(Sender: TObject; var Key: Char);
var Item: TCustomRVItemInfo;
RV: TCustomRichViewEdit;
begin
rve.GetCurrentItemEx(TRVTableItemInfo, RV, Item);
FCurrInTable := Item is TRVTableItemInfo;
if not FCurrInTable then Key :=#0;
end;
procedure TfrmAppMain.rvePaste(Sender: TCustomRichViewEdit;
var Item: TCustomRVItemInfo;
RV: TCustomRichViewEdit;
begin
rve.GetCurrentItemEx(TRVTableItemInfo, RV, Item);
FCurrInTable := Item is TRVTableItemInfo;
DoDefault := FCurrInTable;
end;
How to detect the caret position only before or after a table?
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Posts: 38
- Joined: Sat Nov 06, 2010 5:12 am
Sergey Tkachenko wrote:The caret is inside table cell, if rve.InplaceEditor<>nil.
But all this code is not necessary.
If you protect the paragraph used for the table, the user will not be able to enter text outside the table.
How do you insert this table?
Yes,
I need user cann't insert anything at out of table. but I need user can press a button to call my program code to insert something. how to do?
-
- Posts: 38
- Joined: Sat Nov 06, 2010 5:12 am
Thank Sergey again.
this code working fine.
this code working fine.
Code: Select all
procedure TfrmAppMain.rveKeyPress(Sender: TObject; var Key: Char);
var Item: TCustomRVItemInfo;
RV: TCustomRichViewEdit;
begin
rve.GetCurrentItemEx(TRVTableItemInfo, RV, Item);
FCurrInTable := Item is TRVTableItemInfo;
if (rve.InplaceEditor = nil) and (FCurrInTable) then
begin
Key := #0;
Exit;
end;
if not FCurrInTable then Key := #0;
end;
procedure TfrmAppMain.rvePaste(Sender: TCustomRichViewEdit;
var DoDefault: Boolean);
var Item: TCustomRVItemInfo;
RV: TCustomRichViewEdit;
begin
rve.GetCurrentItemEx(TRVTableItemInfo, RV, Item);
FCurrInTable := Item is TRVTableItemInfo;
if (rve.InplaceEditor = nil) and (FCurrInTable) then
begin
DoDefault := False;
Exit;
end;
DoDefault := FCurrInTable;
end;
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Can you explain why do you choose a complex solution using events instead of simple solution using a paragraph protection?
If you still want to use events, OnKeyPress and OnPaste are not enough.
If you did not turn off drag&drop (i.e. if rve.AcceptDragDropFormats property is not empty), it is still possible to insert outside this table using a drag&drop.
You can either forbid accepting drag&drop by removing all values from rve.AcceptDragDropFormats, or use OnOleDragOver and OnOleDrop events:
If you still want to use events, OnKeyPress and OnPaste are not enough.
If you did not turn off drag&drop (i.e. if rve.AcceptDragDropFormats property is not empty), it is still possible to insert outside this table using a drag&drop.
You can either forbid accepting drag&drop by removing all values from rve.AcceptDragDropFormats, or use OnOleDragOver and OnOleDrop events:
Code: Select all
procedure TForm3.RichViewEdit1OleDragOver(Sender: TCustomRichView;
Shift: TShiftState; X, Y: Integer;
PossibleDropEffects: TRVOleDropEffects;
var DropEffect: TRVOleDropEffect);
var RVData: TCustomRVFormattedData;
ItemNo, Offs: Integer;
P: TPoint;
begin
P := Sender.ClientToDocument(Point(X, Y));
Sender.GetItemAt(P.X, P.Y, RVData, ItemNo, Offs, False);
if RVData=Sender.RVData then
DropEffect := rvdeNone;
end;
procedure TForm3.RichViewEdit1OleDrop(Sender: TCustomRichView;
const DataObject: IDataObject; Shift: TShiftState; X, Y: Integer;
PossibleDropEffects: TRVOleDropEffects; var DropEffect: TRVOleDropEffect;
var DoDefault: Boolean);
var RVData: TCustomRVFormattedData;
ItemNo, Offs: Integer;
P: TPoint;
begin
P := Sender.ClientToDocument(Point(X, Y));
Sender.GetItemAt(P.X, P.Y, RVData, ItemNo, Offs, False);
if RVData=Sender.RVData then begin
DropEffect := rvdeNone;
DoDefault := False;
end;
end;
-
- Posts: 38
- Joined: Sat Nov 06, 2010 5:12 am
I want user cannot modify the content outside of table, but my program can insert , modify the content outside of table , if use your previous suggestion , my program cannot insert something outside of table.
I have found the issue of my complex solution about drag
&drop. Thank you for your kindy suggestion.
by the way, have any other simple method ?
I have found the issue of my complex solution about drag
&drop. Thank you for your kindy suggestion.
by the way, have any other simple method ?
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact: