Here's the alternative implementation: Escape will always return
mrCancel, both LCL's own CreatemessageDialog and
Widgetset.PromptUser().
See attached file: msgdlg.alternative.diff
(Diff's for the first solution are in the bugtracker)
Bart
Index: lcl/dialogs.pp
===================================================================
--- lcl/dialogs.pp (revision 36898)
+++ lcl/dialogs.pp (working copy)
@@ -562,11 +562,12 @@
cBitmapY = 10; // y-position for bitmap in messagedialog
cLabelSpacing = 10; // distance between icon & label
- DialogResult : Array[mrNone..mrYesToAll] of Longint = (
+ DialogResult : Array[mrNone..mrLast] of Longint = (
-1, idButtonOK, idButtonCancel, idButtonAbort, idButtonRetry,
idButtonIgnore, idButtonYes,idButtonNo, idButtonAll, idButtonNoToAll,
- idButtonYesToAll);
+ idButtonYesToAll,idButtonClose);
+
DialogButtonKind : Array[idButtonOK..idButtonNoToAll] of TBitBtnKind = (
bkOk, bkCancel, bkHelp, bkYes, bkNo, bkClose, bkAbort, bkRetry,
bkIgnore, bkAll, bkYesToAll, bkNoToAll);
Index: lcl/include/promptdialog.inc
===================================================================
--- lcl/include/promptdialog.inc (revision 36898)
+++ lcl/include/promptdialog.inc (working copy)
@@ -47,7 +47,7 @@
procedure TPromptDialog.PromptDialogKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if (Key = VK_Escape) then
- ModalResult := -1;
+ ModalResult := mrCancel;
end;
function TPromptDialog.CreateButtons(AVerticalLayout: Boolean;
@@ -75,7 +75,6 @@
begin
Parent:= Self;
Layout := blGlyphLeft;
- OnKeyDown := @PromptDialogKeyDown;
Kind := DialogButtonKind[Buttons[curBtn]];
@@ -129,6 +128,7 @@
IsSmallDevice := (Screen.Width <= 300);
AutoScroll := False;
+ KeyPreview := True;
OnKeyDown := @PromptDialogKeyDown;
//debugln('TPromptDialog.CreateMessageDialog A ButtonCount=',dbgs(ButtonCount));
@@ -261,7 +261,6 @@
begin
Parent:= Self;
Layout := blGlyphLeft;
- OnKeyDown := @PromptDialogKeyDown;
Kind := DialogButtonKind[Buttons[curBtn]];
if Height < Glyph.Height + 5 then
Height := Glyph.Height + 5;
Index: lcl/include/messagedialogs.inc
===================================================================
--- lcl/include/messagedialogs.inc (revision 36898)
+++ lcl/include/messagedialogs.inc (working copy)
@@ -30,40 +30,6 @@
- User ability to customize Button order
}
-function ModalEscapeValue(Buttons: TMsgDlgButtons): TModalResult;
-begin
- If mbCancel in Buttons then
- Result := mrCancel
- else
- If mbNo in Buttons then
- Result := mrNo
- else
- If mbAbort in Buttons then
- Result := mrAbort
- else
- If mbIgnore in Buttons then
- Result := mrIgnore
- else
- If mbNoToAll in Buttons then
- Result := mrNoToAll
- else
- If mbYes in Buttons then
- Result := mrYes
- else
- If mbOk in Buttons then
- Result := mrOk
- else
- If mbRetry in Buttons then
- Result := mrRetry
- else
- If mbAll in Buttons then
- Result := mrAll
- else
- If mbYesToAll in Buttons then
- Result := mrYesToAll
- else
- Result := mrCancel;
-end;
function ModalDefaultButton(Buttons : TMsgDlgButtons) : TMsgDlgbtn;
var
@@ -132,7 +98,8 @@
begin
if (Buttons = []) or (Buttons = [mbHelp]) then
Buttons := Buttons + [mbOk];
- CancelValue := ButtonResults[ModalEscapeValue(Buttons)];
+ //PromptUser() dialog should return mrCancel on Escape or [X]-bordericon
+ CancelValue := idButtonCancel;
if UseDefButton then
DefaultButton := DefButton
else
--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus