Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Feature Request - Confirmation before closing chart screen

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Feature Request - Confirmation before closing chart screen

    This has happened to me several times and I have lost valuable settings and drawings because I accidentally closed the chart screen. The app MUST ask to confirm exiting from chart window or ask to save the current workspace. This is a very critical feature that is missing.

    #2
    Hello shanshan1001,

    Thank you for your post.

    This feature is already available within NinjaTrader, but is not set as default because many users find it irritating to have to confirm a dialog box each time.

    Go to Tools > Options > General and the very first option will be "Confirm on window or tab close". Check this box to activate this setting.

    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      In an AddOn, I have found that with this Option enabled and after the user responds No, there seem to be a number of side effects:
      • Any subscribed Closing event for an NTWindow created by the AddOn is invoked
      • Various reference variables declared in AddOnBase have been set to null, including any references to the NTWindow itself. This can lead to unexpected (and apparently unpreventable) null reference exceptions.
      Questions:
      1. When this Option is enabled, is there a way to detect that a window has been prevented from closing by the user responding No?
      2. Are the side effects noted above intended?
      3. Can the side effects above be prevented?
      Thanks.
      Last edited by jeronymite; 05-02-2021, 03:21 AM.

      Comment


        #4
        Hello jeronymite,

        Thank you for your post.

        There is no supported way to determine if the user clicked no, but you could confirm if the window was in fact closed with something like this:

        protected override void OnWindowDestroyed(Window window)
        {
        if (window is AddonShellWindow)
        Print("This Window closed");
        }

        I'd be happy to ask our development team whether the side effects you mentioned appear to be occurring of setting reference variables to null is intended when using this option is intentional or not. I would need a simplified example add-on that reproduces the issues you're seeing in order to report this to them. If you can provide a simplified example add-on that illustrates the issues you're seeing we can move forward on that.

        Thanks in advance; I look forward to assisting you further.
        Kate W.NinjaTrader Customer Service

        Comment


          #5
          Thanks, Kate.

          Determining that the window is closed is easy, given that it will traverse both the Closing event and OnWindowDestroyed.

          Determining that the window is not closed is the challenge. Answering No to the Confirmation prompt does not prevent the Closing event from being invoked. This causes all the pre-closure actions to be performed no matter what. If the window subsequently is not actually closed, all those actions have irreversibly changed the window context and (probably) other contexts as well.

          If the user answers No to the Confirmation prompt, the Closing event must not be invoked.

          I have modified the standard NinjaTrader AddOnFramework example with some very small changes to demonstrate that the Closing event is invoked when the user answers No to the prompt. It is attached. My changes are very clearly delineated with "//#########" comments.

          Thanks.

          AddOnFramework.zip

          Comment


            #6
            Hello jeronymite,

            Thank you for your reply.

            Are you doing anything in AddOnFrameworkWindowClosing(object sender, CancelEventArgs e), such as setting variables back to null? Are you checking whether e.Cancel is true or false before doing anything else in AddOnFrameWorkWindowClosing()?

            Here's some publicly available documentation from Microsoft regarding CancelEventArgs:

            https://docs.microsoft.com/en-us/dot...s?view=net-5.0

            Thanks in advance; I look forward to assisting you further.
            Kate W.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Frank1000, Today, 03:05 AM
            0 responses
            3 views
            0 likes
            Last Post Frank1000  
            Started by ntdev, Today, 01:14 AM
            1 response
            7 views
            0 likes
            Last Post NT-Roland  
            Started by ct, Today, 02:22 AM
            0 responses
            5 views
            0 likes
            Last Post ct
            by ct
             
            Started by yodaler, Yesterday, 06:12 PM
            3 responses
            11 views
            0 likes
            Last Post yodaler
            by yodaler
             
            Started by sinpeople, 05-07-2021, 04:38 AM
            2 responses
            21 views
            0 likes
            Last Post hedgeplay  
            Working...
            X