mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-09 08:29:06 +02:00
Object Inspector: Remember last active property. Issue #29510, patch from Balázs Székely.
git-svn-id: trunk@51440 -
This commit is contained in:
parent
d89ec8e399
commit
915691f819
@ -721,6 +721,7 @@ type
|
||||
FEnableHookGetSelection: boolean;
|
||||
FInSelection: Boolean;
|
||||
FOnAutoShow: TNotifyEvent;
|
||||
FLastActiveRowName: String;
|
||||
function GetComponentPanelHeight: integer;
|
||||
function GetInfoBoxHeight: integer;
|
||||
procedure SetEnableHookGetSelection(AValue: boolean);
|
||||
@ -805,6 +806,7 @@ type
|
||||
property ShowInfoBox: Boolean read FShowInfoBox write SetShowInfoBox;
|
||||
property ShowRestricted: Boolean read FShowRestricted write SetShowRestricted;
|
||||
property ShowStatusBar: Boolean read FShowStatusBar write SetShowStatusBar;
|
||||
property LastActiveRowName: string read FLastActiveRowName;
|
||||
end;
|
||||
|
||||
const
|
||||
@ -4737,8 +4739,14 @@ begin
|
||||
end;
|
||||
|
||||
procedure TObjectInspectorDlg.OnGridSelectionChange(Sender: TObject);
|
||||
var
|
||||
Row: TOIPropertyGridRow;
|
||||
begin
|
||||
if Assigned(FOnSelectionChange) then FOnSelectionChange(Self);
|
||||
Row := GetActivePropertyRow;
|
||||
if Assigned(Row) then
|
||||
FLastActiveRowName := Row.Name;
|
||||
if Assigned(FOnSelectionChange) then
|
||||
FOnSelectionChange(Self);
|
||||
end;
|
||||
|
||||
function TObjectInspectorDlg.OnGridPropertyHint(Sender: TObject;
|
||||
|
64
ide/main.pp
64
ide/main.pp
@ -399,6 +399,7 @@ type
|
||||
procedure ToolBarOptionsClick(Sender: TObject);
|
||||
private
|
||||
fBuilder: TLazarusBuilder;
|
||||
fOIActivateLastRow: Boolean;
|
||||
function DoBuildLazarusSub(Flags: TBuildLazarusFlags): TModalResult;
|
||||
procedure ProjectOptionsHelper(AFilter: array of TAbstractIDEOptionsClass);
|
||||
// Global IDE events
|
||||
@ -646,7 +647,6 @@ type
|
||||
FFixingGlobalComponentLock: integer;
|
||||
OldCompilerFilename, OldLanguage: String;
|
||||
OIChangedTimer: TIdleTimer;
|
||||
|
||||
procedure DoDropFilesAsync(Data: PtrInt);
|
||||
procedure RenameInheritedMethods(AnUnitInfo: TUnitInfo; List: TStrings);
|
||||
function OIHelpProvider: TAbstractIDEHTMLProvider;
|
||||
@ -8596,24 +8596,13 @@ end;
|
||||
|
||||
procedure TMainIDE.OnDesignerComponentAdded(Sender: TObject;
|
||||
AComponent: TComponent; ARegisteredComponent: TRegisteredComponent);
|
||||
var
|
||||
Grid: TOICustomPropertyGrid;
|
||||
Row: TOIPropertyGridRow;
|
||||
begin
|
||||
TComponentPalette(IDEComponentPalette).DoAfterComponentAdded(TDesigner(Sender).LookupRoot,
|
||||
AComponent, ARegisteredComponent);
|
||||
if EnvironmentOptions.CreateComponentFocusNameProperty
|
||||
and (ObjectInspector1<>nil) then begin
|
||||
if (ObjectInspector1.ShowFavorites) and (EnvironmentOptions.SwitchToFavoritesOITab) then
|
||||
Grid:=ObjectInspector1.FavoriteGrid
|
||||
else
|
||||
Grid:=ObjectInspector1.PropertyGrid;
|
||||
ObjectInspector1.ActivateGrid(Grid);
|
||||
Row:=Grid.GetRowByPath('Name');
|
||||
if Row<>nil then begin
|
||||
Grid.ItemIndex:=Row.Index;
|
||||
ObjectInspector1.FocusGrid(Grid);
|
||||
end;
|
||||
if (ObjectInspector1 <> nil) then
|
||||
begin
|
||||
fOIActivateLastRow := True;
|
||||
OIChangedTimer.AutoEnabled := True;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -11825,7 +11814,8 @@ end;
|
||||
procedure TMainIDE.OIChangedTimerTimer(Sender: TObject);
|
||||
var
|
||||
OI: TObjectInspectorDlg;
|
||||
ARow: TOIPropertyGridRow;
|
||||
Row: TOIPropertyGridRow;
|
||||
Grid: TOICustomPropertyGrid;
|
||||
Code: TCodeBuffer;
|
||||
Caret: TPoint;
|
||||
i: integer;
|
||||
@ -11839,17 +11829,37 @@ begin
|
||||
OIChangedTimer.AutoEnabled:=false;
|
||||
OIChangedTimer.Enabled:=false;
|
||||
|
||||
// Select again the last grid / property after a new component was added
|
||||
if fOIActivateLastRow then
|
||||
begin
|
||||
fOIActivateLastRow := False;
|
||||
if EnvironmentOptions.CreateComponentFocusNameProperty then
|
||||
begin
|
||||
if (OI.ShowFavorites) and (EnvironmentOptions.SwitchToFavoritesOITab) then
|
||||
Grid := OI.FavoriteGrid
|
||||
else
|
||||
Grid := OI.PropertyGrid;
|
||||
Row := Grid.GetRowByPath('Name');
|
||||
end
|
||||
else begin //focus to the last active property(row)
|
||||
Grid := OI.PropertyGrid;
|
||||
Row := Grid.GetRowByPath(OI.LastActiveRowName);
|
||||
end;
|
||||
if Row <> nil then
|
||||
begin
|
||||
OI.ActivateGrid(Grid);
|
||||
OI.FocusGrid(Grid);
|
||||
Grid.ItemIndex := Row.Index;
|
||||
end;
|
||||
end
|
||||
else
|
||||
Row := OI.GetActivePropertyRow;
|
||||
|
||||
// Get help text for this property
|
||||
if not BeginCodeTools or not OI.ShowInfoBox then
|
||||
Exit;
|
||||
|
||||
HtmlHint := '';
|
||||
BaseURL := '';
|
||||
PropDetails := '';
|
||||
|
||||
ARow := OI.GetActivePropertyRow;
|
||||
|
||||
if (ARow <> nil)
|
||||
and FindDeclarationOfOIProperty(OI, ARow, Code, Caret, i) then
|
||||
if (Row <> nil)
|
||||
and FindDeclarationOfOIProperty(OI, Row, Code, Caret, i) then
|
||||
begin
|
||||
if CodeHelpBoss.GetHTMLHint(Code, Caret.X, Caret.Y, [],
|
||||
BaseURL, HtmlHint, PropDetails, CacheWasUsed) <> chprSuccess then
|
||||
@ -11860,6 +11870,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
// Update InfoPanel contents with the help text
|
||||
if OI.InfoPanel.ControlCount > 0 then
|
||||
OI.InfoPanel.Controls[0].Visible := HtmlHint <> '';
|
||||
if HtmlHint <> '' then
|
||||
@ -11872,6 +11883,7 @@ begin
|
||||
Stream.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
// Property details always starts with "published property". Get rid of it.
|
||||
i:=Pos(' ', PropDetails);
|
||||
if i>0 then begin
|
||||
|
Loading…
Reference in New Issue
Block a user