diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/gui_editcombo.pas | 48 | ||||
-rw-r--r-- | src/gui/gui_form.pas | 7 | ||||
-rw-r--r-- | src/gui/messagedialog.inc | 3 |
3 files changed, 43 insertions, 15 deletions
diff --git a/src/gui/gui_editcombo.pas b/src/gui/gui_editcombo.pas index 63dcbec4..27164a5e 100644 --- a/src/gui/gui_editcombo.pas +++ b/src/gui/gui_editcombo.pas @@ -141,7 +141,9 @@ implementation uses gui_listbox, + gui_dialogs, gfx_UTF8utils, + gfx_constants, math; var @@ -272,7 +274,28 @@ begin begin if Assigned(FDropDown) then FDropDown.Close; - inc(FSelectedItem); // with FSelectedItem set to -2 for delete key and -4 for return key + case FSelectedItem of + -3: + begin + FSelectedItem:= -1; + Self.SetFocus; + end; + -2: + begin + case FAllowNew of + anNo: + if FSelectedItem = -2 then + begin + UTF8Delete(FText, FCursorPos, 1); + Dec(FCursorPos); + end; + + anAsk, + anYes: + FNewItem:= True; + end; + end; + end; end else begin @@ -298,9 +321,7 @@ begin anAsk, anYes: if FSelectedItem = -1 then - begin FNewItem:= True; - end; end; { case } end; { if/else } FCursorPos := UTF8Length(FText); @@ -470,8 +491,8 @@ begin DoOnChange; if consumed then - RePaint - else + RePaint; +// else inherited HandleKeyChar(AText, shiftstate, consumed); end; @@ -489,6 +510,7 @@ begin begin if HasText then FocusItem := -1; + FSelectedItem := -3; // detects backspace has been pressed if FCursorPos > 0 then begin UTF8Delete(FText, FCursorPos, 1); @@ -511,11 +533,17 @@ begin if FSelectedItem > -1 then SetText(Items[FSelectedItem]) else - SetText(FText); - FSelectedItem := -4; // detects return has been pressed (must be 4 due to number of repaints) - if FNewItem and (FAllowNew = anYes) then - FItems.Add(FText); - DoOnDropDown; + FocusItem:= -1; + FSelectedItem := -4; // detects return has been pressed + if FNewItem then + case FAllowNew of + anYes: + FItems.Add(FText); + anAsk: + if TfpgMessageDialog.Question(rsNewItemDetected, Format(rsAddNewItem, [FText])) = mbYes then + FItems.Add(FText); + end; + FDropDown.Close; end; else diff --git a/src/gui/gui_form.pas b/src/gui/gui_form.pas index 088a5b40..abcee416 100644 --- a/src/gui/gui_form.pas +++ b/src/gui/gui_form.pas @@ -65,11 +65,11 @@ type procedure HandleMove(x, y: TfpgCoord); override; procedure HandleResize(awidth, aheight: TfpgCoord); override; procedure HandleKeyPress(var keycode: word; var shiftstate: TShiftState; var consumed: boolean); override; - procedure AfterConstruction; override; - procedure BeforeDestruction; override; procedure DoOnClose(var CloseAction: TCloseAction); virtual; public constructor Create(AOwner: TComponent); override; + procedure AfterConstruction; override; + procedure BeforeDestruction; override; procedure AfterCreate; virtual; procedure Show; procedure Hide; @@ -222,8 +222,6 @@ begin FMinHeight := 32; FModalResult := 0; FFullScreen := False; - - AfterCreate; end; procedure TfpgForm.AfterCreate; @@ -336,6 +334,7 @@ end; procedure TfpgForm.AfterConstruction; begin inherited AfterConstruction; + AfterCreate; if Assigned(FOnCreate) then FOnCreate(self); end; diff --git a/src/gui/messagedialog.inc b/src/gui/messagedialog.inc index 25e52a1c..c6fefa5c 100644 --- a/src/gui/messagedialog.inc +++ b/src/gui/messagedialog.inc @@ -1121,7 +1121,7 @@ type class procedure AboutFPGui(const ATitle: string = ''); class function Critical(const ATitle: string; const AText: string; AButtons: TfpgMsgDlgButtons = [mbOK]; ADefaultButton: TfpgMsgDlgBtn = mbNoButton): TfpgMsgDlgBtn; class function Information(const ATitle: string; const AText: string; AButtons: TfpgMsgDlgButtons = [mbOK]; ADefaultButton: TfpgMsgDlgBtn = mbNoButton): TfpgMsgDlgBtn; - class function Question(const ATitle: string; const AText: string; AButtons: TfpgMsgDlgButtons = [mbOK]; ADefaultButton: TfpgMsgDlgBtn = mbNoButton): TfpgMsgDlgBtn; + class function Question(const ATitle: string; const AText: string; AButtons: TfpgMsgDlgButtons = [mbYes, mbNo]; ADefaultButton: TfpgMsgDlgBtn = mbNo): TfpgMsgDlgBtn; class function Warning(const ATitle: string; const AText: string; AButtons: TfpgMsgDlgButtons = [mbOK]; ADefaultButton: TfpgMsgDlgBtn = mbNoButton): TfpgMsgDlgBtn; property InformativeText: string read GetInformativeText write SetInformativeText; property Text: string read FText write SetText; @@ -1393,6 +1393,7 @@ end; constructor TfpgMessageDialog.Create(AOwner: TComponent); begin inherited Create(AOwner); + FButtonList := TList.Create; FMaxLineWidth := 400; FFont := fpgGetFont('#Label1'); |