[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Multiple-button Message boxes not behaving according to documentation


On Mon, 15 Jul 2024 at 23:23, T Lee Davidson <t.lee.davidson@xxxxxxxxx>
wrote:

> On 7/15/24 16:37, Gianluigi wrote:
> > Il 15/07/24 22:27, Gianluigi ha scritto:
> >> Il 15/07/24 21:36, T Lee Davidson ha scritto:
> >>> The documentation states:
> >>> [quote]
> >>> The last button is always assumed to be the cancel and the default
> >>> button.
> >>>
> >>> This is the same button that is triggered when you close the message
> box
> >>> with the ESCAPE key.
> >>>
> >>> In other words, the default action should always do nothing.
> >>> [/quote]
> >>>
> >>> However, given the following code in a Qt5 graphical application:
> >>> [code]
> >>> Public Sub Form_Close()
> >>>
> >>>    If Message.Question("Are you sure you wish to quit.", "Yes",
> >>> "Cancel") = 2 Then Stop Event
> >>>
> >>> End
> >>> [/code]
> >>>
> >>> The default button is the first one. It is shown highlighted and is
> >>> activated when Return/Enter is pressed.
> >>> The Esc button activates the Cancel button as expected.
> >>>
> >>
> >> Hi Lee
> >>
> >> and so:
> >>
> >> Public Sub Form_Close()
> >>
> >>    Message.DefaultButton = False
> >>    If Message.Question("Are you sure you wish to quit.", "Yes",
> >> "Cancel") = 2 Then Stop Event
> >>
> >> End
> >>
> >> Regards
> >> Gianluigi
> >>
> >>
> >
> > The mess was made when the functioning of message was changed compared
> > to before.
> > The default wiki instead says that the default button is always the
> first...
> >
> > Regards
> > Gianluigi
> >
> >
>
> Thank you for your responses, Gianluigi.
>
> So then, it appears that the documentation is incorrect, or at least
> misleading/incomplete. Agreed?
>

Agreed , a quick study of the code shows

if Message.DefaultButton is false then no buttons get the hButton.Default =
True
if It "is" set to True then the first button gets hButton.Default = True

The Last button always gets hButton.Cancel = True

It's possible each toolkit might have their own, er, features.

Respects
BruceS

Follow-Ups:
Re: Multiple-button Message boxes not behaving according to documentationT Lee Davidson <t.lee.davidson@xxxxxxxxx>