Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2011-01

Modal forms: block parent form or application

7 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

cobines

Hello,

I have two forms Form1 and Form2. Form1 is MainForm with ShowInTaskbar=stDefault and Form2 has ShowInTaskbar=True, so they both have taskbar buttons, I treat them as separate windows. I show a modal form from Form2 which blocks the whole application. Is it possible to have it block only Form2, so I can still activate and work in Form1?

cobines

Reply by email

zeljko
to cobines
cobines wrote 7 lines
Hello, I have two forms Form1 and Form2. Form1 is MainForm with ShowInTaskbar=stDefault and Form2 has ShowInTaskbar=True, so they both have taskbar buttons, I treat them as separate windows. I show a modal form from Form2 which blocks the whole application. Is it possible to have it block only Form2, so I can still activate and work in Form1?

There are 2 kinds of modality (at least under qt, but can be applied to any X11 app ... don't know for win32 or mac how to do that). 1.Window modal
2.App modal
So, with proper implementation it's possible to make 1.Form modal for 1 form eg. parent form
2.Form modal for application (usual behaviour).

zeljko

Reply by email

Paul Ishenin
to cobines: I have two forms Form1 and Form2. Form1 is MainForm with ShowInTaskbar=stDefault and…
cobines wrote 7 lines
Hello, I have two forms Form1 and Form2. Form1 is MainForm with ShowInTaskbar=stDefault and Form2 has ShowInTaskbar=True, so they both have taskbar buttons, I treat them as separate windows. I show a modal form from Form2 which blocks the whole application. Is it possible to have it block only Form2, so I can still activate and work in Form1?

Yes. You don't need a modal form then.

1. Change your modal form to be a regular form with PopupParent = Form2.
2. Disable Form2 when you show your popup form.

Of course the logic requires a small reimplementation because you can't use ModalResult and Show is not a blocking method as ShowModal.

Best regards,
Paul Ishenin

Reply by email

cobines
to zeljko: There are 2 kinds of modality (at least under qt, but can be applied to any X11 app ...…

2011/1/29 zeljko :

Show quoted text 16 lines
On Saturday 29 of January 2011 09:29:02 cobines wrote: > Hello, > > I have two forms Form1 and Form2. Form1 is MainForm with > ShowInTaskbar=stDefault and Form2 has ShowInTaskbar=True, so they both > have taskbar buttons, I treat them as separate windows. I show a modal > form from Form2 which blocks the whole application. Is it possible to > have it block only Form2, so I can still activate and work in Form1? There are 2 kinds of modality (at least under qt, but can be applied to any X11 app ... don't know for win32 or mac how to do that). 1.Window modal 2.App modal So, with proper implementation it's possible to make 1.Form modal for 1 form eg. parent form 2.Form modal for application (usual behaviour).

I also think it is like that on GTK2, at least that's how I saw it in one application (medit).

In Windows only parent window (and all its children I think) is blocked, since each window is independent. For example, you can create two windows and in both show modal dialog boxes and switch between them via Alt-Tab, yet still have a third window completely operational.

cobines

Reply by email

cobines
to Paul Ishenin: Yes. You don't need a modal form then. 1. Change your modal form to be a regular form…

2011/1/29 Paul Ishenin :

Show quoted text 17 lines
29.01.2011 15:29, cobines wrote: > > Hello, > > I have two forms Form1 and Form2. Form1 is MainForm with > ShowInTaskbar=stDefault and Form2 has ShowInTaskbar=True, so they both > have taskbar buttons, I treat them as separate windows. I show a modal > form from Form2 which blocks the whole application. Is it possible to > have it block only Form2, so I can still activate and work in Form1? Yes. You don't need a modal form then. 1. Change your modal form to be a regular form with PopupParent = Form2. 2. Disable Form2 when you show your popup form. Of course the logic requires a small reimplementation because you can't use ModalResult and Show is not a blocking method as ShowModal.

OK, I can do this for some of my forms. I thought maybe there was some switch so that modal forms do not block application.

But what about dialog boxes with buttons requiring user input? Usually you want to have result which button was pressed and such dialog boxes are shown as modal with ModalResult returned. Showing OpenFile dialog, showing messages with ShowMessage or asking user for input with InputQuery, all such cases result in all windows in the application being blocked.

Maybe there should be a change how modal forms are treated and allow blocking only parent. Or is this also how Delphi does it?

cobines

Reply by email

Andreas Schneider
to cobines
cobines wrote 6 lines
But what about dialog boxes with buttons requiring user input? Usually you want to have result which button was pressed and such dialog boxes are shown as modal with ModalResult returned. Showing OpenFile dialog, showing messages with ShowMessage or asking user for input with InputQuery, all such cases result in all windows in the application being blocked.

Well, IMHO these windows are called "dialog" for a reason. If you were in a dialog with me and I asked you something, I would be offended if you turned away, talked to a bunch of other people first and THEN come back to finally answer my question.
Or more specifically in these cases: if you click a button to enter some information (InputQuery), you most likely already know - or should know - what you want to enter. Similarly for the Open/Save Dialogs. If you intent on saving or opening a file, you usually have in mind which one. So why should you be able to click around in other windows in that time?

Best Regards, Andreas

Reply by email

cobines
to Andreas Schneider

2011/1/30 Andreas Schneider :

Show quoted text 19 lines
On Sunday, January 30, 2011 00:13 cobines wrote: > But what about dialog boxes with buttons requiring user input? Usually > you want to have result which button was pressed and such dialog boxes > are shown as modal with ModalResult returned. Showing OpenFile dialog, > showing messages with ShowMessage or asking user for input with > InputQuery, all such cases result in all windows in the application > being blocked. Well, IMHO these windows are called "dialog" for a reason. If you were in ?a dialog with me and I asked you something, I would be offended if you turned away, talked to a bunch of other people first and THEN come back to finally answer my question. Or ?more ?specifically ?in these cases: if you click a button to enter some ?information ?(InputQuery), ?you ?most ?likely ?already know - or should ?know ?- ?what ?you ?want to enter. Similarly for the Open/Save Dialogs. ?If ?you intent on saving or opening a file, you usually have in ?mind which one. So why should you be able to click around in other windows in that time?

Well, I look at other native applications, they behave differently than Lazarus applications, hence I ask if that's intended difference. That's all.

cobines

Reply by email