I get on a other post a routine similar to this, to control CTRL+B:
procedure TFrmEditorSimple.DBWPRT_LOCALEDITORKeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
var
bToggle: Boolean;
begin
with DBWPRT_LOCALEDITOR do
begin
bToggle := (Key in [Integer('B'), Integer('U'), Integer('I')])
and (Shift = [ssctrl]);
if bToggle then
Changing;
if bToggle and (Key = Integer('B')) then
TextCursor.CurrAttribute.ToggleCharstyle(WPSTY_BOLD)
else if (Key = Integer('I')) then
TextCursor.CurrAttribute.ToggleCharstyle(WPSTY_ITALIC)
else if (Key = Integer('U')) then
TextCursor.CurrAttribute.ToggleCharstyle(WPSTY_UNDERLINE);
if bToggle then
Key := 0;
end;
end;
But there is a problem here. If I dont have nothing selected, then I press Ctrl+B the words show me BOLD, this is ok, but when I post the record the \b not put around the text that i write after i pressed CTRL+B.
If I select some word on text and press CTRL+B then all works!
If you post the data and then type again the data will be actually reloaded. That changes the writing mode since the writing mode will have to be adjusted to the cursor position.
No julian, I have used wprichtext no dbaware and I have the same behavior.
Follow this steps:
procedure TForm.WPRichText1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
var v: Integer;
begin
if (Key = Integer('B')) and (Shift = [ssctrl]) then
begin WPRichText1.TextCursor.CurrAttribute.ToggleCharstyle(WPSTY_BOLD);
Key := 0;
end
else if (Key = Integer('I')) and (Shift = [ssctrl]) then
begin WPRichText1.TextCursor.CurrAttribute.ToggleCharstyle(WPSTY_ITALIC);
Key := 0;
end
else if (Key = Integer('U')) and (Shift = [ssctrl]) then
begin WPRichText1.TextCursor.CurrAttribute.ToggleCharstyle(WPSTY_UNDERLINE);
Key := 0;
end;
end;
Teste 1:
typesome text, press CTRL+B, type more text, press CTRL+B Result of Wprich.AsString on Teste 1
{\rtf1\ansi\...
{\plain\fs24 mvm\b mvmvmvmvm\b0 \par }}
Teste 2:
typesome text, press CTRL+B, type more text, DON'T press CTRL+B again Result of Wprich.AsString on Teste 2
{\rtf1\ansi\...
{\plain\fs24 mvm mvmvmvmvm\par }}
WPRichText1.TextCursor.CurrAttribute.ToggleCharstyle(...) just work if there is a selection or if your press shortcut, type something and press the shortcut again.
Put 2 wprichtexts, 2 buttons and 1 memo on form:
type something at wpr1;
press CTRL+B;
type some word at wpr1 yet (it will set to bold)!
but....
click on btn1 (memo1.lines.text := wpr1.asstring)
click on btn2 (wpr2.asstring := memo1.lines.text)
U will see that the bold text not is show on wpr2.
#5♥ 0
This category is archived. No new posts are possible.