TrvCustomEditorAction.OnShowing, OnHide

<< Click to display table of contents >>

TrvCustomEditorAction.OnShowing, OnHide

Occurs before Form is shown, and when it is hidden.

property OnShowing: TRVShowFormEvent;
property OnHide: TNotifyEvent;

Example

This example shows how to work with a form displayed by TrvActionEditNote.

Let the main form TfrmMain have:

RichViewEdit: TRichViewEdit – the main editor;

RVAControlPanel1: TRVAControlPanel;

RVAPopupMenu1: TRVAPopupMenu;

rvActionEditNote1: TrvActionEditNote;

rvActionStyleInspector1: TrvActionStyleInspector;

cmbFont: TRVFontComboBox;

cmbFontSize: TRVFontSizeComboBox;

cmbStyles: TRVStyleTemplateComboBox.

We want to insert Form at the bottom of TfrmMain.

Initial property settings:

 RVAControlPanel1.DefaultControl := RichViewEdit1;

 rvActionStyleInspector1.Control := RichViewEdit1;

 cmbFont.Editor := RichViewEdit1;

 cmbFontSize.Editor := RichViewEdit1;

 cmbStyles.Editor := RichViewEdit1

 

// OnFormCreate event

procedure TfrmMain.rvActionEditNoteFormCreate(Sender: TrvAction;

  Form: TForm);
begin

  // assigning properties of the note editor
  rvActionEditNote1.SubDocEditor.OnEnter := NoteEditorEnter;
  rvActionEditNote1.SubDocEditor.OnExit := NoteEditorExit;
  rvActionEditNote1.SubDocEditor.PopupMenu := RVAPopupMenu1;
  // moving the form to the bottom of frmMain
  Form.Align := alBottom;
  Form.Height := 100;
  Form.Parent := Self;
end;

 

// OnShowing event

procedure TfrmMain.rvActionEditNoteShowing(Sender: TrvAction;

  Form: TForm);
begin
  // leaving the current note in RichViewEdit1 highlighted 

  // after moving the input focus
  RichViewEdit1.ForceFieldHighlight := True;
end;

 

// OnHide event
procedure TfrmMain.rvActionEditNoteHide(Sender: TObject);
begin

  // restoring old values of properties
  RichViewEdit1.ForceFieldHighlight := False;
  // focusing the main editor
  if RichViewEdit1.CanFocus then
    RichViewEdit1.SetFocus;
end;

 

// OnEnter: occurs when the input focus is moved to the note editor
procedure TfrmMain.NoteEditorEnter(Sender: TObject);
begin
  // making the note editor default
  RVAControlPanel1.DefaultControl :=

    rvActionsResource.rvActionEditNote1.SubDocEditor;
  UpdateLinkedControls;
end;

 

// OnExit: making the main editor default
procedure TfrmMain.NoteEditorExit(Sender: TObject);
begin
  RVAControlPanel1.DefaultControl := RichViewEdit1;
  UpdateLinkedControls;
end;

 

procedure TfrmMain.UpdateLinkedControls;
begin
  rvActionStyleInspector1.Control := RVAControlPanel1.DefaultControl;
  cmbFont.Editor := RVAControlPanel1.DefaultControl;
  cmbFontSize.Editor := RVAControlPanel1.DefaultControl;
  cmbStyles.Editor := RVAControlPanel1.DefaultControl;
end;

Note: a note editor is special, it redirects many actions (for example, TrvActionNew, TrvActionSave, TrvActionPrint) to the main editor.