WPCubed Product Support

Wrong behaivor Ctrl+B

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!

What the problem?

#1 ♥ 0
5.3k Views 1 links 2 users read 3 min

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 }}

#3 ♥ 0
support

Which version of WPTools is this - I cannot see any problem here.

#4 ♥ 0

5.20.4

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:

  1. type something at wpr1;
  2. press CTRL+B;
  3. type some word at wpr1 yet (it will set to bold)!

but....

  1. click on btn1 (memo1.lines.text := wpr1.asstring)
  2. 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.