From 5240a28f21b2c802dca8d5612516f52ce7d69a98 Mon Sep 17 00:00:00 2001 From: graemeg Date: Fri, 25 Apr 2008 10:20:06 +0000 Subject: * Updated some widgets to handle the Keypad Enter key as well. * Updated the UI Designer so F11 works switching between Properties Editor and Form Designer. * Updated the UI Designer so that New Form and Size or Position dialog accepts values when Enter is pressed. --- examples/apps/uidesigner/newformdesigner.pas | 6 ++-- examples/apps/uidesigner/uidesigner.lpr | 2 +- examples/apps/uidesigner/vfddesigner.pas | 35 ++++++++++------------ examples/apps/uidesigner/vfdfile.pas | 2 +- examples/apps/uidesigner/vfdforms.pas | 45 ++++++++++++++++++++-------- examples/apps/uidesigner/vfdmain.pas | 2 +- examples/apps/uidesigner/vfdwidgetclass.pas | 2 +- examples/apps/uidesigner/vfdwidgets.pas | 2 +- 8 files changed, 57 insertions(+), 39 deletions(-) (limited to 'examples/apps') diff --git a/examples/apps/uidesigner/newformdesigner.pas b/examples/apps/uidesigner/newformdesigner.pas index 4bd4c4c6..175e4fa6 100644 --- a/examples/apps/uidesigner/newformdesigner.pas +++ b/examples/apps/uidesigner/newformdesigner.pas @@ -635,11 +635,13 @@ procedure TfrmProperties.AfterCreate; procedure TfrmProperties.HandleKeyPress(var keycode: word; var shiftstate: TShiftState; var consumed: boolean); begin - if (keycode = keyEnter) or (keycode = keyF11) then + if keycode = keyF11 then begin if maindsgn.selectedform <> nil then + begin maindsgn.selectedform.Form.SetFocus; -// GfxActivateWindow(maindsgn.selectedform.Form.WinHandle); + maindsgn.selectedform.Form.ActivateWindow; + end; consumed := True; end else diff --git a/examples/apps/uidesigner/uidesigner.lpr b/examples/apps/uidesigner/uidesigner.lpr index d39cac22..4b4c371f 100644 --- a/examples/apps/uidesigner/uidesigner.lpr +++ b/examples/apps/uidesigner/uidesigner.lpr @@ -1,7 +1,7 @@ { fpGUI - Free Pascal GUI Library - Copyright (C) 2006 - 2007 See the file AUTHORS.txt, included in this + Copyright (C) 2006 - 2008 See the file AUTHORS.txt, included in this distribution, for details of the copyright. See the file COPYING.modifiedLGPL, included in this distribution, diff --git a/examples/apps/uidesigner/vfddesigner.pas b/examples/apps/uidesigner/vfddesigner.pas index 1ab14a5d..6eb79b9b 100644 --- a/examples/apps/uidesigner/vfddesigner.pas +++ b/examples/apps/uidesigner/vfddesigner.pas @@ -778,20 +778,24 @@ procedure TFormDesigner.DesignerKeyPress(var keycode: word; var shiftstate: TShi SelectNextWidget(True); // tab forward end; - keyF1: ShowMessage('ENTER, F11: switch to Properties' + LineEnding + + keyF1: + ShowMessage('F11: switch to Properties' + LineEnding + 'TAB, SHIFT+TAB: select next widget' + LineEnding + - 'F2: edit widget order' + LineEnding + - 'F4: edit items' + LineEnding - , 'Small help'); + 'F2: edit widget order' + LineEnding {+ + 'F4: edit items' + LineEnding}, 'Small help'); - keyF2: EditWidgetOrder; + keyF2: + EditWidgetOrder; - //KEY_F4: if PropertyForm.btnEdit.Visible then PropertyForm.btnEdit.Click; + //keyF4: + //if frmProperties.btnEdit.Visible then + //frmProperties.btnEdit.Click; - keyF11, - keyEnter: - frmProperties.SetFocus; -// GfxActivateWindow(frmProperties.WinHandle); + keyF11: + begin + frmProperties.SetFocus; + frmProperties.ActivateWindow; + end; else consumed := False; end; @@ -1132,8 +1136,7 @@ procedure TFormDesigner.OnPropNameChange(Sender: TObject); procedure TFormDesigner.OnPropPosEdit(Sender: TObject); var frm: TEditPositionForm; - btn: TfpgButton; - ax, + ax: TfpgCoord; ay: TfpgCoord; wg: TfpgWidget; n: integer; @@ -1168,14 +1171,8 @@ procedure TFormDesigner.OnPropPosEdit(Sender: TObject); if wg = nil then wg := Form; - btn := TfpgButton(Sender); frm := TEditPositionForm.Create(nil); - btn.WindowToScreen(btn, pt); -// GfxGetAbsolutePosition(btn.WinHandle, btn.Width, 0, ax, ay); - ax := pt.X; - ay := pt.Y; - frm.Left := ax; - frm.Top := ay; + if Sender = frmProperties.btnLeft then begin frm.lbPos.Text := 'Left:'; diff --git a/examples/apps/uidesigner/vfdfile.pas b/examples/apps/uidesigner/vfdfile.pas index 8c6ab122..15e23d75 100644 --- a/examples/apps/uidesigner/vfdfile.pas +++ b/examples/apps/uidesigner/vfdfile.pas @@ -1,7 +1,7 @@ { fpGUI - Free Pascal GUI Library - Copyright (C) 2006 - 2007 See the file AUTHORS.txt, included in this + Copyright (C) 2006 - 2008 See the file AUTHORS.txt, included in this distribution, for details of the copyright. See the file COPYING.modifiedLGPL, included in this distribution, diff --git a/examples/apps/uidesigner/vfdforms.pas b/examples/apps/uidesigner/vfdforms.pas index 61b33b29..508b64bf 100644 --- a/examples/apps/uidesigner/vfdforms.pas +++ b/examples/apps/uidesigner/vfdforms.pas @@ -1,7 +1,7 @@ { fpGUI - Free Pascal GUI Library - Copyright (C) 2006 - 2007 See the file AUTHORS.txt, included in this + Copyright (C) 2006 - 2008 See the file AUTHORS.txt, included in this distribution, for details of the copyright. See the file COPYING.modifiedLGPL, included in this distribution, @@ -49,7 +49,7 @@ TInsertCustomForm = class(TVFDDialog) l2: TfpgLabel; edClass: TfpgEdit; edName: TfpgEdit; - btnOK, + btnOK: TfpgButton; btnCancel: TfpgButton; procedure AfterCreate; override; procedure OnButtonClick(Sender: TObject); @@ -57,10 +57,13 @@ TInsertCustomForm = class(TVFDDialog) TNewFormForm = class(TVFDDialog) + private + procedure OnedNameKeyPressed(Sender: TObject; var KeyCode: word; + var ShiftState: TShiftState; var Consumed: boolean); public l1: TfpgLabel; edName: TfpgEdit; - btnOK, + btnOK: TfpgButton; btnCancel: TfpgButton; procedure AfterCreate; override; procedure OnButtonClick(Sender: TObject); @@ -68,10 +71,13 @@ TNewFormForm = class(TVFDDialog) TEditPositionForm = class(TVFDDialog) + private + procedure edPosKeyPressed(Sender: TObject; var KeyCode: word; + var ShiftState: TShiftState; var Consumed: boolean); public lbPos: TfpgLabel; edPos: TfpgEdit; - btnOK, + btnOK: TfpgButton; btnCancel: TfpgButton; procedure AfterCreate; override; procedure OnButtonClick(Sender: TObject); @@ -134,7 +140,8 @@ implementation uses vfdmain, fpgfx, - gui_iniutils; + gui_iniutils, + gfx_constants; { TPaletteForm } @@ -198,6 +205,13 @@ procedure TInsertCustomForm.OnButtonClick(Sender: TObject); { TNewFormForm } +procedure TNewFormForm.OnedNameKeyPressed(Sender: TObject; var KeyCode: word; + var ShiftState: TShiftState; var Consumed: boolean); +begin + if (KeyCode = keyEnter) or (KeyCode = keyPEnter) then + btnOK.Click; +end; + procedure TNewFormForm.AfterCreate; begin inherited AfterCreate; @@ -208,8 +222,9 @@ procedure TNewFormForm.AfterCreate; l1 := CreateLabel(self, 8, 8, 'Form name:'); edName := CreateEdit(self, 8, 28, 180, 0); edName.Text := 'frm'; - btnOK := CreateButton(self, 196, 8, 80, 'OK', @OnButtonClick); - btnCancel := CreateButton(self, 196, 36, 80, 'Cancel', @OnButtonClick); + edName.OnKeyPress := @OnedNameKeyPressed; + btnOK := CreateButton(self, 196, 8, 80, rsOK, @OnButtonClick); + btnCancel := CreateButton(self, 196, 36, 80, rsCancel, @OnButtonClick); end; procedure TNewFormForm.OnButtonClick(Sender: TObject); @@ -222,6 +237,13 @@ procedure TNewFormForm.OnButtonClick(Sender: TObject); { TEditPositionForm } +procedure TEditPositionForm.edPosKeyPressed(Sender: TObject; var KeyCode: word; + var ShiftState: TShiftState; var Consumed: boolean); +begin + if (KeyCode = keyEnter) or (KeyCode = keyPEnter) then + btnOK.Click; +end; + procedure TEditPositionForm.AfterCreate; begin inherited AfterCreate; @@ -233,12 +255,9 @@ procedure TEditPositionForm.AfterCreate; lbPos := CreateLabel(self, 8, 8, 'Pos: '); edPos := CreateEdit(self, 8, 28, 80, 0); - btnOK := CreateButton(self, 100, 8, 75, 'OK', @OnButtonClick); - btnCancel := CreateButton(self, 100, 36, 75, 'Cancel', @OnButtonClick); - btnOK.ImageName := 'stdimg.ok'; - btnOK.ShowImage := True; - btnCancel.ImageName := 'stdimg.cancel'; - btnCancel.ShowImage := True; + edPos.OnKeyPress := @edPosKeyPressed; + btnOK := CreateButton(self, 98, 8, 80, rsOK, @OnButtonClick); + btnCancel := CreateButton(self, 98, 36, 80, rsCancel, @OnButtonClick); end; procedure TEditPositionForm.OnButtonClick(Sender: TObject); diff --git a/examples/apps/uidesigner/vfdmain.pas b/examples/apps/uidesigner/vfdmain.pas index 1b139e61..53145c6d 100644 --- a/examples/apps/uidesigner/vfdmain.pas +++ b/examples/apps/uidesigner/vfdmain.pas @@ -1,7 +1,7 @@ { fpGUI - Free Pascal GUI Library - Copyright (C) 2006 - 2007 See the file AUTHORS.txt, included in this + Copyright (C) 2006 - 2008 See the file AUTHORS.txt, included in this distribution, for details of the copyright. See the file COPYING.modifiedLGPL, included in this distribution, diff --git a/examples/apps/uidesigner/vfdwidgetclass.pas b/examples/apps/uidesigner/vfdwidgetclass.pas index e1b57f50..19308b35 100644 --- a/examples/apps/uidesigner/vfdwidgetclass.pas +++ b/examples/apps/uidesigner/vfdwidgetclass.pas @@ -1,7 +1,7 @@ { fpGUI - Free Pascal GUI Library - Copyright (C) 2006 - 2007 See the file AUTHORS.txt, included in this + Copyright (C) 2006 - 2008 See the file AUTHORS.txt, included in this distribution, for details of the copyright. See the file COPYING.modifiedLGPL, included in this distribution, diff --git a/examples/apps/uidesigner/vfdwidgets.pas b/examples/apps/uidesigner/vfdwidgets.pas index ac415fe3..73088160 100644 --- a/examples/apps/uidesigner/vfdwidgets.pas +++ b/examples/apps/uidesigner/vfdwidgets.pas @@ -1,7 +1,7 @@ { fpGUI - Free Pascal GUI Library - Copyright (C) 2006 - 2007 See the file AUTHORS.txt, included in this + Copyright (C) 2006 - 2008 See the file AUTHORS.txt, included in this distribution, for details of the copyright. See the file COPYING.modifiedLGPL, included in this distribution, -- cgit v1.2.3-54-g00ecf