Discussion:
[Lazarus] Lazarus 1.6 and QuestionDLG
Jürgen Hestermann
2015-12-13 15:38:39 UTC
Permalink
I just saw that with Lazarus 1.6 QuestionDLG has been changed (too).
My code:

Answer := QuestionDlg('File overwrite',S2,
mtConfirmation,[mrNo, '&No','IsDefault',
mrYes, '&Yes',
mrIgnore,'ne&Ver',
mrAll, 'a&LL',
488, '&Older files only',
588, 'files with different &Size and date only',
188, 'copy/move with &Different name',
288, 'rename existing &Target file (prior to '+S+')',
388, '&Compare files',
mrAbort, '&Abort '+S],0);

(with S2 beeing the text) showed this dialog with Lazarus 1.4 :




Now it looks like this:



The idea of using a TMemo is not bad but then it should have the width of the
window so that my text is not broken into more lines than neseccary.


Also, the escape key no longer selects mrAbort.
I cannot exit from the dialog with escape.
Is this intended?
Juha Manninen
2015-12-13 17:30:54 UTC
Permalink
On Sun, Dec 13, 2015 at 5:38 PM, JÃŒrgen Hestermann <
Post by Jürgen Hestermann
The idea of using a TMemo is not bad but then it should have the width of the
window so that my text is not broken into more lines than neseccary.
Mattias committed in r50570 :
LCL: default QuestionDlg: use TMemo when text too big
Revisions 50572 and 50574 also deal with QuestionDlg.

Yes, the Memo should be resized together with the dialog window, using
anchors for example.
Can you please open a bug report.

Juha
Mattias Gaertner
2015-12-14 17:20:40 UTC
Permalink
On Sun, 13 Dec 2015 19:30:54 +0200
On Sun, Dec 13, 2015 at 5:38 PM, Jürgen Hestermann <
Post by Jürgen Hestermann
The idea of using a TMemo is not bad but then it should have the width of the
window so that my text is not broken into more lines than neseccary.
LCL: default QuestionDlg: use TMemo when text too big
Revisions 50572 and 50574 also deal with QuestionDlg.
Yes, the Memo should be resized together with the dialog window, using
anchors for example.
Can you please open a bug report.
I made the dialog resizable in case a memo is shown.

Mattias

--
Jürgen Hestermann
2015-12-13 16:59:40 UTC
Permalink
Post by Jürgen Hestermann
Also, the escape key no longer selects mrAbort.
I cannot exit from the dialog with escape.
Is this intended?
The escape key selects mrCancel now (this was changed) - but you should definitely be able to exit the dialog with escape. See http://bugs.freepascal.org/view.php?id=26019 .
As you may have seen from my code snippet I do not use mrCancel.
What happens in this case?
Should mrAbort used instead?
At least I am (no longer) able to exit from this dialog with Escape (on Windows 8.1)
If you have any trouble with the code change, please attach a sample project so that we can discuss it more precisely.
I would have no problem to switch from mrAbort to mrCancel.
I am just wondering, why Escape no longer lets me exit at all.

Nevertheless, the TMemo issue is more severe to me
(even though I am planning to write my own QuestionDLG but
this may take a while, too many other things in the pipeline....)
Mattias Gaertner
2015-12-14 17:19:42 UTC
Permalink
On Sun, 13 Dec 2015 19:44:34 +0100
[...]
The memo width is computed from the text. But the width should be
increased with the scrollbar and memo border width so that the text fits
inside. If this is done, the memo doesn't have to be maximized (although
it can) - Mattias added support for the memo, so I let him decide.
Fixed.

Mattias

--
Jürgen Hestermann
2015-12-19 10:17:26 UTC
Permalink
The escape key selects mrCancel now (this was changed) -
I am not sure I understand this right.
Does it mean, mrCancel needs to be
checked too in a case statement like this?

case QuestionDlg('COPYING',
'Abort?',
mtConfirmation,
[mrNo, '&No','IsDefault',
mrYes,'&Yes'],0) of
mrYes : ...
mrNo : ...
end; // of case

Can the result be mcCancel even when it's not part
of the parameter list of the QuestionDlg function?
That would be strange.

--
Mattias Gaertner
2015-12-19 15:34:16 UTC
Permalink
On Sat, 19 Dec 2015 11:17:26 +0100
Post by Jürgen Hestermann
The escape key selects mrCancel now (this was changed) -
I am not sure I understand this right.
Does it mean, mrCancel needs to be
checked too in a case statement like this?
case QuestionDlg('COPYING',
'Abort?',
mtConfirmation,
[mrNo, '&No','IsDefault',
mrYes,'&Yes'],0) of
mrYes : ...
mrNo : ...
end; // of case
Can the result be mcCancel even when it's not part
of the parameter list of the QuestionDlg function?
Yes. Many widgetsets support an Escape key and/or have a close button.
That's why there is the 'IsCancel' option to redirect the cancel
to a button of your choice.

I fixed the case where a button is 'IsDefault' and 'IsCancel'.


Mattias

--
Jürgen Hestermann
2015-12-20 11:32:45 UTC
Permalink
Post by Mattias Gaertner
Post by Jürgen Hestermann
Can the result be mcCancel even when it's not part
of the parameter list of the QuestionDlg function?
Yes. Many widgetsets support an Escape key and/or have a close button.
That's why there is the 'IsCancel' option to redirect the cancel
to a button of your choice.
I just had a look at this
http://wiki.freepascal.org/Dialog_Examples#QuestionDlg
but I can't find any mentioning of 'IsCancel'.

It also says:
"If the user cancels the dialog, be sure to check the result! In the above code, the result on cancelling the original dialog will be mrNo."
That seems to be wrong if the result is always mrCancel.


--
Jürgen Hestermann
2015-12-20 11:52:12 UTC
Permalink
I just add that you had to care for mrCancel before as well (if default dialog was shown).
It was returned when the dialog was closed with the system close button in the window caption. So the test code you sent isn't good for 1.4 either.
Before (with Lazarus 1.4) typing escape had the expected behaviour.
Now (with Lazarus 1.6) the same code does nothing on escape.
So something has changed.
no 'iscancel' button defined: mrCancel is returned on ESC/close.
'iscancel' defined: its modal result is always returned on ESC/close.
As already written in my other mail there is no documentation of 'iscancel' on
http://wiki.freepascal.org/Dialog_Examples#QuestionDlg
and here
http://lazarus-ccr.sourceforge.net/docs/lcl/dialogs/questiondlg.html
neither 'isdefault' nor 'iscancel' is mentioned.

I simply did not know about 'iscancel' at all.
How should I, if it's undocumented?

--
Jürgen Hestermann
2015-12-20 16:51:21 UTC
Permalink
It's a feature from trunk added by me on Dec 13th 2015 and it is documented in trunk (although with some delay).
I also merged it to 1.6 branch on Dec 14th 2015. Don't get me wrong - I don't want to be offensive but I expect
everybody asking for bug fixes to check the trunk/fixes_1_6 SVN changes. You cannot see the implementation details otherwise.
I did not even know that 'iscancel' is a bug fix.
I thought it existed in version 1.4 too.
You have to understand that new features in trunk are being developed and so they can change.
How do I know what are new features?
I just upgraded from Lazarus 1.4 to Lazarus 1.6 RC1
not knowing that the latter is just a development version.
I never use(d) trunk versions.
Writing a documentation for features in development is not very reasonable.
Realy?
I thought that it is very important to document the *intended*
behaviour somewhere before (or at least while) coding it
so that everybody knows how things *should* work and
can distinguish bugs from features.
Without documentation every bug becomes an intended behaviour.
Always look for documentation in trunk or the fixes branch.
Where do I find it?
I use official (pre) releases only.
It is told to be updated with new stable versions so now it should reflect 1.4.
Of course you don't find the latest features there.
Okay, so the main reason for my problems is that I did not wait until the
official release of Lazarus 1.6. I thought that RC1 should already be stable
and wanted to help with testing (expecting only minor bugs only).
But it seems that was not a good idea.
As latest, you have the source code, so you can check it as well - that usually is better than any documentation.
You cannot mean this seriously, do you?
You mean I should wade through *all* the
lines of code and understand each and every
line to discover new features and how they work?
Otherwise I would not have known that 'iscancel' was added recently.
There could be changes in many other functions too.

What if there is a bug?
When looking at the code I would consider this bug
to be an intended behaviour and rely on it (until it
gets fixed and bytes me back).

Not a good advice IMO.


--
Michael Van Canneyt
2015-12-20 17:18:11 UTC
Permalink
Post by Jürgen Hestermann
You cannot mean this seriously, do you?
You mean I should wade through *all* the
lines of code and understand each and every
line to discover new features and how they work?
Yes, I mean this seriously. You don't have to go through all the code, just
the code that doesn't work as you expect. I do the same - if there is
something I don't understand or it behaves differently from the docs, I look
into the code and check why.
That is why I only ever use components that come with source code.
The source is always the best reference for anything.

Michael.

--
Jürgen Hestermann
2015-12-21 10:45:01 UTC
Permalink
Post by Jürgen Hestermann
Where do I find it?
I use official (pre) releases only.
* Added 'iscancel' parameter to QuestionDlg. If no cancel button is explicitely set, mrCancel is returned in case the dialog is closed with ESC or system close button.
I added it there on Dec 14th 2015...
Well, I downloaded RC1 on Dec 10th and read the release notes before
but it came not to my mind to read it again daily just in case some changes
were made (to the changes ;-)).

Loading...