Take the RichViewActions demo as an example, I expected that pressing TAB will indent the entire list item, but it's not, it indents the texts after the bullet points instead.
How to use [Tab]/[Shift -Tab] to indent/outdent an entire list item line, like that in MS Word?
Thanks.
How to enable Tab key to indent bulleted lists?
-
- Site Admin
- Posts: 17566
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: How to enable Tab key to indent bulleted lists?
More exactly, MS Word increases/decreases list level.
You can do it by including the following code in TRichViewEdit.OnKeyDown:
You can do it by including the following code in TRichViewEdit.OnKeyDown:
Code: Select all
procedure TForm3.RichViewEdit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
var
rve: TCustomRichViewEdit;
begin
rve := (Sender as TCustomRichViewEdit).TopLevelEditor;
if (Key = VK_TAB) and not (ssCtrl in Shift) and
not rve.SelectionExists and
(rve.CurItemNo > 0) and
(rve.OffsetInCurItem = rve.GetOffsBeforeItem(rve.CurItemNo)) and
(rve.GetItemStyle(rve.CurItemNo - 1) = rvsListMarker)
then
begin
if ssShift in Shift then
rve.ChangeListLevels(-1)
else
rve.ChangeListLevels(1);
Key := 0;
Include(rve.RVData.State, rvstIgnoreNextChar);
end;
end;
Re: How to enable Tab key to indent bulleted lists?
Sergey, Thanks!
With the code you provided the TAB/Shift+TAB work, but I can no longer input any character after that, I believe it has something to do with the code:
Any advises? Thanks again.
With the code you provided the TAB/Shift+TAB work, but I can no longer input any character after that, I believe it has something to do with the code:
Code: Select all
Include(rve.RVData.State, rvstIgnoreNextChar)
-
- Site Admin
- Posts: 17566
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: How to enable Tab key to indent bulleted lists?
You are right, sorry.
Instead, add a variable to the form
IgnoreNextTab: Boolean;
OnKeyDown:
OnKeyPress:
Instead, add a variable to the form
IgnoreNextTab: Boolean;
OnKeyDown:
Code: Select all
procedure TForm3.RichViewEdit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
var
rve: TCustomRichViewEdit;
begin
rve := (Sender as TCustomRichViewEdit).TopLevelEditor;
if (Key = VK_TAB) and not (ssCtrl in Shift) and
not rve.SelectionExists and
(rve.CurItemNo > 0) and
(rve.OffsetInCurItem = rve.GetOffsBeforeItem(rve.CurItemNo)) and
(rve.GetItemStyle(rve.CurItemNo - 1) = rvsListMarker)
then
begin
if ssShift in Shift then
rve.ChangeListLevels(-1)
else
rve.ChangeListLevels(1);
Key := 0;
IgnoreNextTab := True;
end;
end;
Code: Select all
procedure TForm3.RichViewEdit1KeyPress(Sender: TObject; var Key: Char);
begin
if IgnoreNextTab then
begin
IgnoreNextTab := False;
if Key = #9 then
Key := #0;
exit;
end;
end;
Re: How to enable Tab key to indent bulleted lists?
Thanks, now it works!