Deleting items with rvprStyleProtect
Deleting items with rvprStyleProtect
We are having an issue is that when a text item is partially selected and has a text style with rvprStyleProtect in its Protection but not rvprStyleDelete, it is annoying to actually delete it. You have to select the whole item first, and then delete/backspace/cut will work. If you only have part of the item selected, RVE will just call System.Beep and do nothing, because the item can't be modified. If the cursor is at the start of the item and you press the Delete key, or at the end of the item and you press Backspace, it will also fail unless the item is only one character long. This is technically correct given how rvprStyleProtect is defined, but not what we would like from a usability standpoint.
Instead, what I would prefer is to delete the whole item whenever there is an attempt to delete any part of it. This certainly doesn't need to be the default behavior for RVEs, but it's what I'm trying to make happen in this case.
We are trying to find a way to detect that the user is trying to delete the item, and before the delete is processed, we will expand the selection to include the entire item. But we cannot find a clean way to do this.
Any other alternative suggestions would be appreciated.
Instead, what I would prefer is to delete the whole item whenever there is an attempt to delete any part of it. This certainly doesn't need to be the default behavior for RVEs, but it's what I'm trying to make happen in this case.
We are trying to find a way to detect that the user is trying to delete the item, and before the delete is processed, we will expand the selection to include the entire item. But we cannot find a clean way to do this.
Any other alternative suggestions would be appreciated.
Last edited by dave novo on Tue Jul 28, 2020 7:52 pm, edited 1 time in total.
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Deleting items with rvprStyleProtect
Ok, I'll add "easy delete" option in the next update.
Re: Deleting items with rvprStyleProtect
Hi Sergey,
Just wondering how the "easy delete" option is coming?
Just wondering how the "easy delete" option is coming?
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Deleting items with rvprStyleProtect
Do you need it urgently? I plan a major new feature in the next update, and it will take some time.
Re: Deleting items with rvprStyleProtect
Is there some hack you can suggest in the meantime. Basically, all we need is some hook that when the delete is about to happen, we have a chance to expand the selection to encompass the entire item and then let the deletion proceed normally since all the text we want will be selected. We can modify the source with your suggestion until you come up with a more elegant solution.
Re: Deleting items with rvprStyleProtect
Hi Sergey,
Just wondering if there was any update on this.
Just wondering if there was any update on this.
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Deleting items with rvprStyleProtect
Sorry, I need to complete the current stage of DocX import before.
I'll be able to send changes to you in the next week.
I'll be able to send changes to you in the next week.
Re: Deleting items with rvprStyleProtect
Hi Sergey,
Any update on this? We have finished all our changes and this is the last part that is remaining
Any update on this? We have finished all our changes and this is the last part that is remaining
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Deleting items with rvprStyleProtect
I cannot upload the new version now, because it has incomplete changes.
But I can explain how to make the necessary changes.
1) RVEdit.pas, a new option in TRVEditorOption type:
rvoFastDeleteProtectedText
2) In RVERVData.pas, the condition of the first IF in Backspace_NotAtTheBeginning function is changed to:
This change allows deleting the protected text by a single press of Backspace or Delete key.
3) The same unit, add the method:
4) Add the call of this method in the function function TRVEditRVData.CanDelete, just after the call of StoreSelBounds:
5) Add the call of this method in the function function TRVEditRVData.DeleteSelection_, just after the SECOND call of StoreSelBounds (where the last parameter is True):
The changes 3-5 allow deleting a protected text together with a selected fragment, even if it (protected text) is selected only partially.
But I can explain how to make the necessary changes.
1) RVEdit.pas, a new option in TRVEditorOption type:
rvoFastDeleteProtectedText
2) In RVERVData.pas, the condition of the first IF in Backspace_NotAtTheBeginning function is changed to:
Code: Select all
if ((StyleNo < 0) and (Offset = 1)) or
((StyleNo >= 0) and IsProtected(DrawItem.ItemNo, rvprModifyProtect) and
(rvoFastDeleteProtectedText in TCustomRichViewEdit(FRichView).EditorOptions)) or
((StyleNo >= 0) and
(GetItemTextLength(DrawItem.ItemNo) <=
DeleteCount(Items[DrawItem.ItemNo], DrawItem.Offs + Offset - 2, DrawItem.ItemNo)) and
((GetRVStyle.TextStyles[StyleNo].EmptyWidth <= 0) or IsWideEmptyTextItem(DrawItem.ItemNo))) then
3) The same unit, add the method:
Code: Select all
procedure TRVEditRVData.AdjustSelectionBeforeDeletion(var StartNo, EndNo, StartOffs, EndOffs: Integer);
begin
if not (rvoFastDeleteProtectedText in TCustomRichViewEdit(FRichView).EditorOptions) then
exit;
if IsProtected(StartNo, rvprModifyProtect) then
StartOffs := GetOffsBeforeItem(StartNo);
if IsProtected(EndNo, rvprModifyProtect) then
EndOffs := GetOffsAfterItem(EndNo);
end;
Code: Select all
StoreSelBounds(StartNo, EndNo, StartOffs, EndOffs, True);
AdjustSelectionBeforeDeletion(StartNo, EndNo, StartOffs, EndOffs);
Code: Select all
StoreSelBounds(StartNo, EndNo, StartOffs, EndOffs, True);
AdjustSelectionBeforeDeletion(StartNo, EndNo, StartOffs, EndOffs);
Re: Deleting items with rvprStyleProtect
Hi Sergey,
Thank you. We will apply the changes and let you know if we encounter any issues.
Thank you. We will apply the changes and let you know if we encounter any issues.