Question

How to create an "application modal" dialog?

  • 6 February 2023
  • 7 replies
  • 92 views

I have a dialog with property “modal” set to “yes” in “Window (Definition Shell)”.
It's opened via a button action from a MDI Child window.

Modal property seems to only set the window to be in “parent modal” state, but I still can interact with all the controls outside the window that the dialog was opened from.
How do I set it to an “application modal”, so the whole application is blocked?


7 replies

Userlevel 2
Badge +1

Hi,

Good question , I see in the help of the Modal property:

Modal windows do not behave like an MDI child window. If you set a window's Modal behavior property to Yes, its MDI Child property is set to No automatically.

Not sure if that’s relevant.

If I try on USoft 10 to set Modal=Yes on some default Dialog (e.g. a custom subclass of the “About Box”), and use WindowCreate(About Box -New) as action on a button that is added to some default info window “Sequence Numbers”, then it properly blocks the whole application:

 

 

Can you tell me which USoft version you are using? Can you give details the button action?

Hi,

Thanks for help, but still no luck.

I'm on version 9.1 I believe.
I tried to recreate the scenario described as close as possible.
 

Sadly, the About Dialog is modal only in regard to the Sequence window.
I cannot push the “Button 1” again or close it.
I can, though, still use the main menu and all the main application toolbar buttons ☹️

Button action set to “WindowCreate(About Box - New)”.
About window set to Modal: Yes, Window Type: Dialog.

 

Userlevel 2
Badge +1

Hi Jakub,

I think this might be a bug, it seems that if you use a color theme other than the Default (View → Color theme), the modal property is ignored for some reason. When you use the default one, it should work. I’ll create a support ticket for this finding so that engineering can have a look at it. Will get back as soon as I have more information! 

Kind regards,

Dara

 

Thanks Dara.
Much appreciated.

I'll check which theme we use, but I probably cannot change it just for that issue. 

Regards, Jakub

Userlevel 2
Badge +2

Dear Jakub,

You open the dialog in the context of an Info Window (MDI child). If you open the dialog in the context of the application, it will be modal for the whole application. In the example below I open the dialog from a SQL Command Box:

action Application().WindowCreate('Dialog Box - New' )

(from a button you can skip the action keyword).

 

Regards,

Robert

Hi Robert,

Thank you.
That looks like what I was looking for 👍
I'll give it a go.

For future reference… how would you do it if you need to pass parameters to the dialog?
(using something like Dialog(<param>).Window.Create() construct...)

Userlevel 2
Badge +2

Hi Jakub,

I created a Window on the Events table and added a button with action:

Application().Dialog_Box_for_Jakub( Self() ).Window().Create()

On the Dialog I set the post-open property to:

Label_1.label( thisLabel() )

I added a user-defined property of Type String to the dialog. Then I ran the Window in the Designer and pushed the button. Here’s the result:

Will that do?

 

Regards,

Robert

Reply