Making a windows form totally modal, preventing Esc-button ?

Questions and answers for designing and implementing forms in Servoy

Making a windows form totally modal, preventing Esc-button ?

Postby Bernd.N » Wed Nov 02, 2016 11:55 pm

We use a small dialog form to add a simple record, which resides in a floating windows form (smart client).
We use the dialog framework for that task which works very well:
https://www.servoyforge.net/projects/mod-dialog

We need to make that dialog form totally modal, and took already the windows header away, so that the user could not close the form with the X on right upper side.
Now we have just one issue left we could not solve:
The user is still able to close that window with the Escape button.

Is there a way to prevent this?

I guess this is a generic question for all windows forms, not only for this dialog framework from Servoy Forge:
How to disable the escape button for forms in windows...
Bernd Korthaus
LinkedIn
Servoy 7.4.9 SC postgreSQL 9.4.11 Windows 10 Pro
User avatar
Bernd.N
 
Posts: 544
Joined: Mon Oct 21, 2013 5:57 pm
Location: Langenhorn, North Friesland, Germany

Re: Making a windows form totally modal, preventing Esc-butt

Postby mboegem » Thu Nov 03, 2016 12:08 am

Hi Bernd,

you can prevent closing any dialog by returning 'false' in the onHide function of the form which you are showing in the dialog.

So I suggest you set a formVariable with a value at the onShow of the form, ie. allowHide = false;
When the user is pressing the buttons you want him to press, you can set the allowHide variable to true.

In the onHide function you'll need to return allowHide.
Code: Select all
function onHide(event) {
   
   //just any code you want to do at onHide
   
   return allowHide;
}
Marc Boegem
Solutiative / JBS Group, Partner
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image

Partner of Tower - The most powerful Git client for Mac and Windows
User avatar
mboegem
 
Posts: 1743
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: Making a windows form totally modal, preventing Esc-butt

Postby Bernd.N » Thu Nov 03, 2016 1:12 am

Hi Marc,
we tried that approach today and somehow it did not work.
But after you suggested it again, I tried again and now it works.
Thank you!
Bernd Korthaus
LinkedIn
Servoy 7.4.9 SC postgreSQL 9.4.11 Windows 10 Pro
User avatar
Bernd.N
 
Posts: 544
Joined: Mon Oct 21, 2013 5:57 pm
Location: Langenhorn, North Friesland, Germany

Re: Making a windows form totally modal, preventing Esc-butt

Postby patrick » Thu Nov 03, 2016 10:49 am

You could also have a look at the svyCustomDialogs scope on github (https://github.com/Servoy/svyUtils/wiki/Custom-Dialogs). It can replace the mod_dialog feature wise and allows you to easily build any kind of simple dialog with any number of components in it (like a simple change password dialog). And a CustomDialog has an onClose property that gives you control over the "X".
Patrick Ruhsert
Servoy DACH
patrick
 
Posts: 3703
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany


Return to Forms

Who is online

Users browsing this forum: No registered users and 4 guests