summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorgraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2008-04-26 07:18:29 +0000
committergraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2008-04-26 07:18:29 +0000
commit3eebee734896aa4a540031b4e9e391eb230f20f2 (patch)
treec7b43fbcbb3c739e2d3b19ad7072d56f6eafe216 /examples
parent7521b35f350b69d438f42d836193c6569b7f38cb (diff)
downloadfpGUI-3eebee734896aa4a540031b4e9e391eb230f20f2.tar.xz
UI Designer's Object Inspector now waits untill you press Enter before text or integer values are set. Changing the focus of a text or integer property without pressing Enter will reset the changes to the previous value. A nice undo feature.
Diffstat (limited to 'examples')
-rw-r--r--examples/apps/uidesigner/vfdprops.pas31
1 files changed, 29 insertions, 2 deletions
diff --git a/examples/apps/uidesigner/vfdprops.pas b/examples/apps/uidesigner/vfdprops.pas
index 32166060..fa2c8cd7 100644
--- a/examples/apps/uidesigner/vfdprops.pas
+++ b/examples/apps/uidesigner/vfdprops.pas
@@ -91,6 +91,11 @@ type
TGeneralPropertyEditor = class(TVFDPropertyEditor)
+ private
+ FOrigValue: string;
+ procedure EditExit(Sender: TObject);
+ procedure EditKeyPressed(Sender: TObject; var KeyCode: word;
+ var ShiftState: TShiftState; var Consumed: boolean);
public
etype: TGPEType;
edit: TfpgEdit;
@@ -274,13 +279,33 @@ end;
{ TGeneralPropertyEditor }
+procedure TGeneralPropertyEditor.EditExit(Sender: TObject);
+begin
+ if FOrigValue <> edit.Text then
+ edit.Text := FOrigvalue;
+end;
+
+procedure TGeneralPropertyEditor.EditKeyPressed(Sender: TObject;
+ var KeyCode: word; var ShiftState: TShiftState; var Consumed: boolean);
+begin
+ if (KeyCode = keyReturn) or (KeyCode = keyPEnter) then
+ begin
+ UpdateProperty(nil);
+ FOrigValue := edit.Text;
+ end
+ else
+ inherited;
+end;
+
procedure TGeneralPropertyEditor.CreateLayout;
begin
Anchors := [anTop, anLeft, anRight];
Edit := TfpgEdit.Create(self);
Edit.SetPosition(0, 0, Width, Height);
Edit.Anchors := Anchors;
- Edit.OnChange := @UpdateProperty;
+// Edit.OnChange := @UpdateProperty;
+ Edit.OnKeyPress := @EditKeyPressed;
+ Edit.OnExit :=@EditExit;
Edit.Visible := True;
end;
@@ -301,10 +326,12 @@ end;
procedure TGeneralPropertyEditor.LoadValue(wg: TfpgWidget);
begin
case etype of
- gptInteger: LoadIntValue(wg);
+ gptInteger:
+ LoadIntValue(wg);
else
LoadStrValue(wg);
end;
+ FOrigValue := edit.Text;
end;
procedure TGeneralPropertyEditor.StoreIntValue(wg: TfpgWidget);