diff --git a/components/codetools/ide/codyidentifiersdlg.lfm b/components/codetools/ide/codyidentifiersdlg.lfm index 411753be27..90d8a8e6b9 100644 --- a/components/codetools/ide/codyidentifiersdlg.lfm +++ b/components/codetools/ide/codyidentifiersdlg.lfm @@ -69,6 +69,7 @@ object CodyIdentifiersDlg: TCodyIdentifiersDlg BorderSpacing.Right = 6 BorderSpacing.Bottom = 1 ItemHeight = 0 + OnContextPopup = ItemsListBoxContextPopup OnDblClick = ItemsListBoxDblClick OnSelectionChange = ItemsListBoxSelectionChange PopupMenu = PopupMenu1 @@ -163,7 +164,6 @@ object CodyIdentifiersDlg: TCodyIdentifiersDlg TabOrder = 6 end object PopupMenu1: TPopupMenu - OnPopup = PopupMenu1Popup left = 177 top = 133 object JumpMenuItem: TMenuItem diff --git a/components/codetools/ide/codyidentifiersdlg.pas b/components/codetools/ide/codyidentifiersdlg.pas index dfb1198bae..af1ec44768 100644 --- a/components/codetools/ide/codyidentifiersdlg.pas +++ b/components/codetools/ide/codyidentifiersdlg.pas @@ -175,7 +175,8 @@ type procedure ItemsListBoxDblClick(Sender: TObject); procedure ItemsListBoxSelectionChange(Sender: TObject; {%H-}User: boolean); procedure OnIdle(Sender: TObject; var {%H-}Done: Boolean); - procedure PopupMenu1Popup(Sender: TObject); + procedure ItemsListBoxContextPopup(Sender: TObject; MousePos: TPoint; + var Handled: Boolean); procedure StartsRadioButtonClick(Sender: TObject); private FDlgAction: TCodyIdentifierDlgAction; @@ -1044,29 +1045,19 @@ begin IdleConnected:=false; end; -procedure TCodyIdentifiersDlg.PopupMenu1Popup(Sender: TObject); +procedure TCodyIdentifiersDlg.ItemsListBoxContextPopup(Sender: TObject; + MousePos: TPoint; var Handled: Boolean); var - Identifier: string; - UnitFilename: string; - GroupName: string; - GroupFilename: string; + Identifier, UnitFilename, GroupName, GroupFilename: string; begin - if FindSelectedItem(Identifier, UnitFilename, GroupName, GroupFilename) then - begin - UseMenuItem.Caption:='Use '+Identifier; - UseMenuItem.Enabled:=true; - JumpMenuItem.Caption:='Jump to '+Identifier; - JumpMenuItem.Enabled:=true; - DeleteUnitMenuItem.Caption:='Delete unit '+ExtractFilename(UnitFilename); - DeleteUnitMenuItem.Enabled:=true; - DeletePackageMenuItem.Caption:='Delete package '+ExtractFilename(GroupFilename); - DeletePackageMenuItem.Enabled:=true; - end else begin - UseMenuItem.Enabled:=false; - JumpMenuItem.Enabled:=false; - DeleteUnitMenuItem.Enabled:=false; - DeletePackageMenuItem.Enabled:=false; - end; + // show popup menu only if valid identificator is selected + Handled := not FindSelectedItem(Identifier, UnitFilename, GroupName, GroupFilename); + if Handled then exit; + + UseMenuItem .Caption := Format(crsContextUseIdentifier, [Identifier]); + JumpMenuItem .Caption := Format(crsContextJumpTo , [Identifier]); + DeleteUnitMenuItem .Caption := Format(crsContextDeleteUnit , [ExtractFilename(UnitFilename)]); + DeletePackageMenuItem.Caption := Format(crsContextDeletePackage, [ExtractFilename(GroupFilename)]); end; procedure TCodyIdentifiersDlg.StartsRadioButtonClick(Sender: TObject); diff --git a/components/codetools/ide/codystrconsts.pas b/components/codetools/ide/codystrconsts.pas index 9b8c47df69..569933289d 100644 --- a/components/codetools/ide/codystrconsts.pas +++ b/components/codetools/ide/codystrconsts.pas @@ -183,6 +183,10 @@ resourcestring +'containing filter text'; crsUseIdentifier = '&Use identifier'; crsAndMoreIdentifiers = '... and %s more identifiers'; + crsContextUseIdentifier = 'Use "%s"'; + crsContextJumpTo = 'Jump to "%s"'; + crsContextDeleteUnit = 'Delete unit "%s"'; + crsContextDeletePackage = 'Delete package "%s"'; crsCodyIdentifierDictionary = 'Identifier Dictionary'; crsReallyDeleteTheUnitFromTheDatabaseNoteThisDoesNo = 'Really delete the ' +'unit from the database?%sNote: This does not change the source or any'