From 8e8285d4b12e2c975a0ccae747a2434fb5b66cd7 Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Wed, 7 Apr 2010 15:24:10 +0200 Subject: Added 'Insert from Character Map' menu item for default popup menu in TfpgEdit Text can now be inserted into a TfpgEdit via the Character Map dialog. --- src/gui/fpg_edit.pas | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gui/fpg_edit.pas b/src/gui/fpg_edit.pas index ba5f16c2..86ae00fc 100644 --- a/src/gui/fpg_edit.pas +++ b/src/gui/fpg_edit.pas @@ -77,6 +77,7 @@ type procedure DefaultPopupCopy(Sender: TObject); procedure DefaultPopupPaste(Sender: TObject); procedure DefaultPopupClearAll(Sender: TObject); + procedure DefaultPopupInsertFromCharmap(Sender: TObject); procedure SetDefaultPopupMenuItemsState; procedure SetReadOnly(const AValue: Boolean); protected @@ -362,7 +363,8 @@ implementation uses fpg_stringutils, - fpg_constants; + fpg_constants, + fpg_dialogs; const // internal popupmenu item names @@ -370,6 +372,7 @@ const ipmCopy = 'miDefaultCopy'; ipmPaste = 'miDefaultPaste'; ipmClearAll = 'miDefaultClearAll'; + ipmCharmap = 'miDefaultCharmap'; function CreateEdit(AOwner: TComponent; x, y, w, h: TfpgCoord): TfpgEdit; @@ -1154,26 +1157,43 @@ end; procedure TfpgBaseEdit.DefaultPopupCut(Sender: TObject); begin + if ReadOnly then + Exit; CutToClipboard; end; procedure TfpgBaseEdit.DefaultPopupCopy(Sender: TObject); begin + if ReadOnly then + Exit; CopyToClipboard; end; procedure TfpgBaseEdit.DefaultPopupPaste(Sender: TObject); begin + if ReadOnly then + Exit; PasteFromClipboard end; procedure TfpgBaseEdit.DefaultPopupClearAll(Sender: TObject); begin if ReadOnly then - Exit; //==> + Exit; Clear; end; +procedure TfpgBaseEdit.DefaultPopupInsertFromCharmap(Sender: TObject); +var + s: TfpgString; +begin + if ReadOnly then + Exit; + s := fpgShowCharMap; + if s <> '' then + DoPaste(s); +end; + procedure TfpgBaseEdit.SetDefaultPopupMenuItemsState; var i: integer; @@ -1192,7 +1212,9 @@ begin else if itm.Name = ipmPaste then itm.Enabled := (not ReadOnly) and (fpgClipboard.Text <> '') else if itm.Name = ipmClearAll then - itm.Enabled := (not ReadOnly) and (Text <> ''); + itm.Enabled := (not ReadOnly) and (Text <> '') + else if itm.Name = ipmCharmap then + itm.Enabled := (not ReadOnly); end; end; end; @@ -1230,6 +1252,10 @@ begin itm.Name := ipmPaste; itm := FDefaultPopupMenu.AddMenuItem(rsDelete, '', @DefaultPopupClearAll); itm.Name := ipmClearAll; + itm := FDefaultPopupMenu.AddMenuItem('-', '', nil); + itm.Name := 'N1'; + itm := FDefaultPopupMenu.AddMenuItem(rsInsertFromCharacterMap, '', @DefaultPopupInsertFromCharmap); + itm.Name := ipmCharmap; end; SetDefaultPopupMenuItemsState; -- cgit v1.2.3-70-g09d2