Source language: Translate to:

Custom Window: detect if user click the close button

Post your suggestions for future versions of NeoBook

Moderator: Neosoft Support

Custom Window: detect if user click the close button

Postby Cipolla » Fri Dec 06, 2013 6:46 am

I need to fire some actions before a user clicks the close button (the red X at the title bar) of a custom window. Just like the shutdown action. I want to pop up a message box,
asking the user if he really want´s to close the CustomWindow. If not, i want the CustomWindow to stay open.

Any Idea, or suggestion for another update?
Greetings from Germany
Klaus
User avatar
Cipolla
 
Posts: 166
Joined: Fri Apr 01, 2005 1:45 am
Location: Germany

Re: Custom Window: detect if user click the close button

Postby HPW » Fri Dec 06, 2013 7:00 am

You may use the NoCloseBtn option for the customwindow and provide your own close-button where you can code what you want.
Hans-Peter
User avatar
HPW
 
Posts: 2520
Joined: Fri Apr 01, 2005 11:24 pm
Location: Germany

Re: Custom Window: detect if user click the close button

Postby Gaev » Fri Dec 06, 2013 7:01 am

Klaus:
I want to pop up a message box,
asking the user if he really want´s to close the CustomWindow. If not, i want the CustomWindow to stay open.

Not sure if you can prevent the Custom Window from closing ... but (from the Help file) ...
You can define special subroutines that will be executed when a specific custom window is opened or closed. To do this, simply create two subroutines - one called ObjectName_OnOpen and one called ObjectName_OnClose. Replace ObjectName with the name of object used when opening the window. For example, the subroutines for our Container1 sample above might look like this:

:Container1_OnOpen
AlertBox "Hello" "The window is opening."
Return
:Container1_OnClose
AlertBox "Hello" "The window is closing."
Return

Would be nice if there was a way to tell NeoBook (in the :Container1_OnClose subroutine) to "Cancel/Ignore the User Request"

Another option would be to use the NoCloseBtn "options" parameter of the CustomWindow command.

Also, you could try using the NoBorder option ... and then simulate title bar and the X with other objects.
User avatar
Gaev
 
Posts: 3736
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: Custom Window: detect if user click the close button

Postby Cipolla » Fri Dec 06, 2013 1:44 pm

HPW wrote:You may use the NoCloseBtn option for the customwindow and provide your own close-button where you can code what you want.
Thanks for your reply.

Yup. i have a Save & Cancel Button on stage, but for the look and feel, the customers wants a "real" windows like red 'X' ;-)

Not sure if you can prevent the Custom Window from closing...


I thought about that, but the subroutine is fired AFTER the window is closed. :-(

Also, you could try using the NoBorder option ... and then simulate title bar and the X with other objects.


Not really an option, because on different systems the windows title bar looks always different.

So it seems there is no native solution.

Dave, is it possible to implement this kind of behaviour?
Greetings from Germany
Klaus
User avatar
Cipolla
 
Posts: 166
Joined: Fri Apr 01, 2005 1:45 am
Location: Germany

Re: Custom Window: detect if user click the close button

Postby Wrangler » Sat Dec 07, 2013 8:54 am

but for the look and feel, the customers wants a "real" windows like red 'X'


This can be done by taking a snapshot of a regular windows window title bar and red 'X'. Then you can superimpose a transparent button over the x and a text box with variable for the title. If done correctly, you can't tell the difference.
Wrangler
--------------
"You never know about a woman. Whether she'll laugh, cry or go for a gun." - Louis L'Amour

Windows 7 Ultimate SP1 64bit
16GB Ram
Asus GTX 950 OC Strix
Software made with NeoBook
http://highdesertsoftware.com
User avatar
Wrangler
 
Posts: 1507
Joined: Thu Mar 31, 2005 11:40 pm
Location: USA

Re: Custom Window: detect if user click the close button

Postby Gaev » Sat Dec 07, 2013 10:22 am

Wrangler:
This can be done by taking a snapshot of a regular windows window title bar and red 'X'. Then you can superimpose a transparent button over the x and a text box with variable for the title. If done correctly, you can't tell the difference.

Will not work if the "windows style" used by his clients is different from the "style on the Developers machine where the image was snapped"
User avatar
Gaev
 
Posts: 3736
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: Custom Window: detect if user click the close button

Postby Wrangler » Sat Dec 07, 2013 10:25 am

Well, then it's a matter of how important that is? How upset could one get that the theme doesn't match their installed theme perfectly? If you used the default windows theme, the odds are you would cover most users anyway.

like red 'X'


I think these are the keywords here. What I propose would fullfill that request.
Wrangler
--------------
"You never know about a woman. Whether she'll laugh, cry or go for a gun." - Louis L'Amour

Windows 7 Ultimate SP1 64bit
16GB Ram
Asus GTX 950 OC Strix
Software made with NeoBook
http://highdesertsoftware.com
User avatar
Wrangler
 
Posts: 1507
Joined: Thu Mar 31, 2005 11:40 pm
Location: USA

Re: Custom Window: detect if user click the close button

Postby Neosoft Support » Sat Dec 07, 2013 1:17 pm

Would be nice if there was a way to tell NeoBook (in the :Container1_OnClose subroutine) to "Cancel/Ignore the User Request"


I will add this to the list of things to consider for the future.

However, the way I would handle this would be to simply hide the close button like the custom window's NoCloseBtn option does. Then give the user a clear option like an OK, Accept or Done button to click when they have completed the necessary steps. The windows "X" button is supposed to mean the same as the "Cancel" button. When collecting input from the user is critical, then there should be no close or cancel options - only OK, Accept, etc.

From Microsoft's Windows Style Guide:

The Close button on the title bar should have the same effect as the Cancel or Close button within the dialog box. Never give it the same effect as OK.
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5603
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Re: Custom Window: detect if user click the close button

Postby Cipolla » Tue Dec 10, 2013 6:44 am

Dave, thank you for putting this on your to do list :)
Greetings from Germany
Klaus
User avatar
Cipolla
 
Posts: 166
Joined: Fri Apr 01, 2005 1:45 am
Location: Germany

Re: Custom Window: detect if user click the close button

Postby Garic » Sat Jun 04, 2016 5:08 am

This feature is implemented in the plugin ksOnMoveSizeCustWin
Using variables [ShutdownSourceCustWin] and [ShutdownStatusCustWin], you can intercept the close button of the custom window.
Look at an example that comes with the plugin.
ks
.............
Image
User avatar
Garic
 
Posts: 107
Joined: Wed Sep 26, 2012 8:42 am


Return to NeoBook Suggestions

Who is online

Users browsing this forum: No registered users and 1 guest