<< Click to Display Table of Contents >> Navigation: Programming > User Interface > Toolbar > Toolbar and Actions, OnOpenDialog |
The TWPToolbar and the actions all call 2 methods in WPCtrRich.pas.
If you need sample code to mimic their way to react on user input, please check out their implementation.
The methods are
procedure OnToolBarSelection(Sender: TObject; var Typ: TWpSelNr;
const str: string; const num: Integer); override;
and
procedure OnToolBarIconSelection(Sender: TObject;
var Typ: TWpSelNr; const str: string; const group, num, index: Integer); virtual;
OnToolBarIconSelection locates the required code by the group and the number of the action.
i.e. change the current font name:
procedure TWPCustomRichText.OnToolBarSelection(
Sender: TObject; var Typ: TWpSelNr;
const str: string; const num: Integer);
begin
inherited OnToolBarSelection(Sender, Typ, str, num);
begin
if Typ <> wptNone then
begin
if (Changing = FALSE) or ReadOnly then
begin
exit;
end;
case Typ of
wptName:
begin
CurrAttr.FontName := str;
end;
....
i.e. switch bold mode on
procedure TWPCustomRichText.OnToolBarIconSelection(Sender: TObject;
var Typ: TWpSelNr; const str: string; const group, num, index: Integer);
...
else if group = WPI_GR_STYLE then
begin
desel := FALSE;
case num of
WPI_CO_BOLD:
begin
if Changing then
begin
CurrAttr.TextStyle([afsBold], true);
ChangeApplied;
end;
Typ := wptNone;
end;
There is also the function OpenDialog.
function OpenDialog(DialogType: TWPCustomRtfEditDialog;
const Param : String = ''): Boolean; override;
It is called to show a dialog such as Open or Save. In many cases the DialogCollection is used to find the required dialog, such as the paragraph property dialog.
To override the behavior assign an event handler to the event OnOpenDialog and set the last parameter to true.