delphi - How do I make standard actions (like TEditCopy) recognize additional controls (like TEmbeddedWB)? -
i satisified functionality of teditcut
, teditcopy
, teditpaste
, teditselectall
except don't work on controls not standard.
for example, may work fine on tedit
or tmemo
controls, not on tembeddedwb
— it, standard actions disabled regardless of whether text selected, though tembeddedwb
has methods copytoclipboard
, selectall
.
how can make standard actions work tembeddedwb
? how standard actions determine whether should enabled or disabled (and in event — in onupdate
event)? can extend standard actions add support unrecognized components, or need write replacement?
the default edit actions not work on tembeddedwb
control, because component not descend tcustomedit
. teditaction
, teditselectall
descends from, knows how handle tcustomedits
.
use onupdate
, onexecute
events of action override behaviour. note default behaviour ignored, implement manually. here example teditselectall
action.
procedure tform1.editselectall1update(sender: tobject); begin editselectall1.enabled := (screen.activecontrol tembeddedwb) or editselectall1.handlestarget(activecontrol) end; procedure tform1.editselectall1execute(sender: tobject); begin if activecontrol tembeddedwb tembeddedwb(screen.activecontrol).selectall else editselectall1.executetarget(screen.activecontrol); end;
or use same events of actionlist (or onactionupdate
, onactionexecute
of applicationevents component) centralize custom behaviour:
procedure tform1.actionlist1update(action: tbasicaction; var handled: boolean); begin if action teditaction begin tcustomaction(action).enabled := (screen.activecontrol tembeddedwb) or action.handlestarget(screen.activecontrol); handled := true; end; end; procedure tform1.actionlist1execute(action: tbasicaction; var handled: boolean); begin if (action teditselectall) , (screen.activecontrol tembeddedwb) begin tembeddedwb(screen.activecontrol).selectall; handled := true; end; end;
Comments
Post a Comment