Can we have a new BeforeLeaveRTFDataBlock event in TWPCustomRtfEdit. This would be implemented as follows:
Code
TWPAllowEvent = procedure(Sender: TWPCustomRtfEdit;
var Allow: Boolean) of object;
FBeforeLeaveRTFDataBlock: TWPAllowEvent;
function TWPCustomRtfEdit.DontAllowLeaveRTFDataBlock: Boolean;
var allow: Boolean;
begin
allow := TRUE;
if assigned(FBeforeLeaveRTFDataBlock) then
FBeforeLeaveRTFDataBlock(Self, allow)
if allow = FALSE then
begin
Result := TRUE;
exit;
end;
if (wpDisableEditOfNonBodyDataBlocks in EditOptionsEx)
or (LayoutMode = wplayLayout) then
with FMemo.Cursor do
begin
if (RTFData = nil) or (RTFData.Kind <> wpIsBody) then
Result := FALSE
else Result := TRUE;
end else Result := FALSE;
end;
Alles anzeigen
This will allow us to lock users into data blocks under program control. In particular, our application will have two distinct edit modes - Body Mode and Header/Footer Mode. Currently we can lock the user into the body using the wpDisableEditOfNonBodyDataBlocks option, but there is no way of locking them out of the body when they are in our Header/Footer Mode. Introducing our proposed event will be much more flexible than creating another EditOptionsEx value such as wpDisableEditOfBodyDataBlocks