IDEIntf: object inspector: fixed SetRowValue checking for focus

git-svn-id: trunk@41866 -
This commit is contained in:
mattias 2013-06-24 12:14:46 +00:00
parent c9f04de233
commit 4a4b3a8ecd

View File

@ -359,7 +359,7 @@ type
procedure SortSubEditors(ParentRow: TOIPropertyGridRow); procedure SortSubEditors(ParentRow: TOIPropertyGridRow);
function CanExpandRow(Row: TOIPropertyGridRow): boolean; function CanExpandRow(Row: TOIPropertyGridRow): boolean;
procedure SetRowValue; procedure SetRowValue(CheckFocus: boolean);
procedure DoCallEdit(Edit: TOIQuickEdit = oiqeEdit); procedure DoCallEdit(Edit: TOIQuickEdit = oiqeEdit);
procedure RefreshValueEdit; procedure RefreshValueEdit;
procedure ToggleRow; procedure ToggleRow;
@ -425,7 +425,7 @@ type
DefItemHeight: integer); DefItemHeight: integer);
destructor Destroy; override; destructor Destroy; override;
function InitHints: boolean; function InitHints: boolean;
function CanEditRowValue: boolean; function CanEditRowValue(CheckFocus: boolean): boolean;
procedure SaveChanges; procedure SaveChanges;
function ConsistencyCheck: integer; function ConsistencyCheck: integer;
procedure EraseBackground(DC: HDC); override; procedure EraseBackground(DC: HDC); override;
@ -1288,7 +1288,7 @@ begin
if s<=length(PropPath) then Result:=nil; if s<=length(PropPath) then Result:=nil;
end; end;
procedure TOICustomPropertyGrid.SetRowValue; procedure TOICustomPropertyGrid.SetRowValue(CheckFocus: boolean);
var var
CurRow: TOIPropertyGridRow; CurRow: TOIPropertyGridRow;
NewValue: string; NewValue: string;
@ -1296,7 +1296,7 @@ var
OldChangeStep: integer; OldChangeStep: integer;
begin begin
//debugln(['TOICustomPropertyGrid.SetRowValue A ',dbgs(FStates*[pgsChangingItemIndex,pgsApplyingValue]<>[]),' FItemIndex=',dbgs(FItemIndex),' CanEditRowValue=',CanEditRowValue]); //debugln(['TOICustomPropertyGrid.SetRowValue A ',dbgs(FStates*[pgsChangingItemIndex,pgsApplyingValue]<>[]),' FItemIndex=',dbgs(FItemIndex),' CanEditRowValue=',CanEditRowValue]);
if not CanEditRowValue or Rows[FItemIndex].IsReadOnly then exit; if not CanEditRowValue(CheckFocus) or Rows[FItemIndex].IsReadOnly then exit;
NewValue:=GetCurrentEditValue; NewValue:=GetCurrentEditValue;
@ -1356,7 +1356,7 @@ var
CurRow:TOIPropertyGridRow; CurRow:TOIPropertyGridRow;
OldChangeStep: integer; OldChangeStep: integer;
begin begin
if not CanEditRowValue then exit; if not CanEditRowValue(true) then exit;
OldChangeStep:=fChangeStep; OldChangeStep:=fChangeStep;
CurRow:=Rows[FItemIndex]; CurRow:=Rows[FItemIndex];
@ -1424,7 +1424,7 @@ end;
procedure TOICustomPropertyGrid.ValueEditExit(Sender: TObject); procedure TOICustomPropertyGrid.ValueEditExit(Sender: TObject);
begin begin
SetRowValue; SetRowValue(false);
end; end;
procedure TOICustomPropertyGrid.ValueEditChange(Sender: TObject); procedure TOICustomPropertyGrid.ValueEditChange(Sender: TObject);
@ -1433,7 +1433,7 @@ begin
if (pgsUpdatingEditControl in FStates) or not IsCurrentEditorAvailable then exit; if (pgsUpdatingEditControl in FStates) or not IsCurrentEditorAvailable then exit;
CurRow:=Rows[FItemIndex]; CurRow:=Rows[FItemIndex];
if paAutoUpdate in CurRow.Editor.GetAttributes then if paAutoUpdate in CurRow.Editor.GetAttributes then
SetRowValue; SetRowValue(true);
end; end;
procedure TOICustomPropertyGrid.ValueEditMouseUp(Sender: TObject; procedure TOICustomPropertyGrid.ValueEditMouseUp(Sender: TObject;
@ -1458,7 +1458,7 @@ end;
procedure TOICustomPropertyGrid.ValueCheckBoxExit(Sender: TObject); procedure TOICustomPropertyGrid.ValueCheckBoxExit(Sender: TObject);
begin begin
SetRowValue; SetRowValue(false);
end; end;
procedure TOICustomPropertyGrid.ValueCheckBoxClick(Sender: TObject); procedure TOICustomPropertyGrid.ValueCheckBoxClick(Sender: TObject);
@ -1469,13 +1469,13 @@ begin
ValueCheckBox.Caption:=BoolToStr(ValueCheckBox.Checked, True); //'True','False'; ValueCheckBox.Caption:=BoolToStr(ValueCheckBox.Checked, True); //'True','False';
CurRow:=Rows[FItemIndex]; CurRow:=Rows[FItemIndex];
if paAutoUpdate in CurRow.Editor.GetAttributes then if paAutoUpdate in CurRow.Editor.GetAttributes then
SetRowValue; SetRowValue(true);
end; end;
procedure TOICustomPropertyGrid.ValueComboBoxExit(Sender: TObject); procedure TOICustomPropertyGrid.ValueComboBoxExit(Sender: TObject);
begin begin
if pgsUpdatingEditControl in FStates then exit; if pgsUpdatingEditControl in FStates then exit;
SetRowValue; SetRowValue(false);
end; end;
procedure TOICustomPropertyGrid.ValueComboBoxKeyDown(Sender: TObject; procedure TOICustomPropertyGrid.ValueComboBoxKeyDown(Sender: TObject;
@ -1531,7 +1531,7 @@ begin
exit; exit;
// save old edit value // save old edit value
SetRowValue; SetRowValue(true);
Include(FStates, pgsChangingItemIndex); Include(FStates, pgsChangingItemIndex);
if (FItemIndex >= 0) and (FItemIndex < FRows.Count) then if (FItemIndex >= 0) and (FItemIndex < FRows.Count) then
@ -1923,12 +1923,12 @@ end;
procedure TOICustomPropertyGrid.SetCurrentRowValue(const NewValue: string); procedure TOICustomPropertyGrid.SetCurrentRowValue(const NewValue: string);
begin begin
if not CanEditRowValue or Rows[FItemIndex].IsReadOnly then exit; if not CanEditRowValue(false) or Rows[FItemIndex].IsReadOnly then exit;
// SetRowValue reads the value from the current edit control and writes it // SetRowValue reads the value from the current edit control and writes it
// to the property editor // to the property editor
// -> set the text in the current edit control without changing FLastEditValue // -> set the text in the current edit control without changing FLastEditValue
SetCurrentEditValue(NewValue); SetCurrentEditValue(NewValue);
SetRowValue; SetRowValue(false);
end; end;
procedure TOICustomPropertyGrid.SetItemIndexAndFocus(NewItemIndex: integer; procedure TOICustomPropertyGrid.SetItemIndexAndFocus(NewItemIndex: integer;
@ -1946,15 +1946,18 @@ begin
end; end;
end; end;
function TOICustomPropertyGrid.CanEditRowValue: boolean; function TOICustomPropertyGrid.CanEditRowValue(CheckFocus: boolean): boolean;
var
FocusedControl: TWinControl;
begin begin
Result:= Result:=
not GridIsUpdating and IsCurrentEditorAvailable not GridIsUpdating and IsCurrentEditorAvailable
and ((FCurrentEditorLookupRoot = nil) and ((FCurrentEditorLookupRoot = nil)
or (FPropertyEditorHook = nil) or (FPropertyEditorHook = nil)
or (FPropertyEditorHook.LookupRoot = FCurrentEditorLookupRoot)); or (FPropertyEditorHook.LookupRoot = FCurrentEditorLookupRoot));
if Result then begin if Result and CheckFocus then begin
if FindControl(GetFocus)<>FCurrentEdit then FocusedControl:=FindControl(GetFocus);
if (FocusedControl<>nil) and not IsParentOf(FocusedControl) then
Result:=false; Result:=false;
end; end;
if Result then begin if Result then begin
@ -1972,7 +1975,7 @@ end;
procedure TOICustomPropertyGrid.SaveChanges; procedure TOICustomPropertyGrid.SaveChanges;
begin begin
SetRowValue; SetRowValue(true);
end; end;
function TOICustomPropertyGrid.GetHintTypeAt(RowIndex: integer; X: integer): TPropEditHint; function TOICustomPropertyGrid.GetHintTypeAt(RowIndex: integer; X: integer): TPropEditHint;
@ -2192,7 +2195,7 @@ var
if Column = oipgcName then if Column = oipgcName then
DoTabKey DoTabKey
else else
SetRowValue; SetRowValue(false);
if FCurrentEdit is TCustomEdit then if FCurrentEdit is TCustomEdit then
TCustomEdit(FCurrentEdit).SelectAll; TCustomEdit(FCurrentEdit).SelectAll;
end; end;
@ -3009,7 +3012,7 @@ end;
procedure TOICustomPropertyGrid.ValueComboBoxCloseUp(Sender: TObject); procedure TOICustomPropertyGrid.ValueComboBoxCloseUp(Sender: TObject);
begin begin
SetRowValue; SetRowValue(false);
end; end;
procedure TOICustomPropertyGrid.ValueComboBoxGetItems(Sender: TObject); procedure TOICustomPropertyGrid.ValueComboBoxGetItems(Sender: TObject);
@ -3240,7 +3243,7 @@ var
CurRow: TOIPropertyGridRow; CurRow: TOIPropertyGridRow;
TypeKind : TTypeKind; TypeKind : TTypeKind;
begin begin
if not CanEditRowValue then exit; if not CanEditRowValue(false) then exit;
if FHintTimer <> nil then if FHintTimer <> nil then
FHintTimer.Enabled := False; FHintTimer.Enabled := False;
@ -3258,7 +3261,7 @@ begin
ValueComboBox.ItemIndex := ValueComboBox.ItemIndex + 1 ValueComboBox.ItemIndex := ValueComboBox.ItemIndex + 1
else else
ValueComboBox.ItemIndex := 0; ValueComboBox.ItemIndex := 0;
SetRowValue; SetRowValue(false);
exit; exit;
end; end;
end; end;