OnChange-event is not executed when changing fontcolor

  • Hi,

    The OnChange-event of TRichText is not fired when changing fontcolor, but when adding/replacing/moving tekst it is fired correctly.
    I use USEDEVEXPRESS.

    What can be a reason why this OnChange-event isn't fired?

    • Offizieller Beitrag

    Hi,

    The interfaces SelectedTextAttr and others are low level - they will not trigger those events.

    As principle the events are not called for interfaces which are only accessible by code. Only user action will trigger the events.

    It is the responsiblity fro the developer to wrap the code in calls to

    if Changing then
    begin

    ChangeApplied
    end;

    Regards,

    Julian

  • I've tried this, but it still is not working they way I want it to be.

    Code
    procedure TFDossierDetails.mbTekstkleurChange(Sender: TObject);
    begin
      If WPTEditor.Changing then
      begin
        WPTEditor.SelectedTextAttr.SetColor(mbTekstkleur.Color);
        WPTEditor.ChangeApplied;
      end;
    end;
  • After some testing I found out the following:

    For changing the textcolor apparently you need to setup two events in order to get it to work:

    Code
    procedure TForm1.mbTextColorChange(Sender: TObject);begin  WPTEditor.SelectedTextAttr.SetColor(mbTextColor.Color);end;procedure TForm1.mbTextColorCurChange(Sender: TObject);begin  If WPTEditor.Changing then    WPTEditor.ChangeApplied;end;

    Where f.e. for the textmarker one event will do nicely:

    Code
    procedure TForm1.mbMarkerChange(Sender: TObject);
    begin
      If WPTEditor.Changing then
      begin
        WPTEditor.SelectedTextAttr.SetBGColor(mbMarker.Color);
        WPTEditor.ChangeApplied;
      end;
    end;

    At least I got it working now.