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.
      Multi-Dimensional Managed Trading
      jeronymite
      NinjaTrader Ecosystem Vendor - Mizpah Software

      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
          Multi-Dimensional Managed Trading
          jeronymite
          NinjaTrader Ecosystem Vendor - Mizpah Software

          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:



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

            Comment


              #7
              Thanks, Kate. As always, appreciate your kind assistance.

              I am now checking e.Cancel, which is true when the user has responded No to the Confirm Close dialogue. This now prevents "inadvertent" window closing activities.

              I will investigate further to see if it also eliminates nulling of variables.

              Thanks.
              Multi-Dimensional Managed Trading
              jeronymite
              NinjaTrader Ecosystem Vendor - Mizpah Software

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by kevinenergy, 02-17-2023, 12:42 PM
              115 responses
              2,699 views
              1 like
              Last Post kevinenergy  
              Started by prdecast, Today, 06:07 AM
              1 response
              4 views
              0 likes
              Last Post NinjaTrader_LuisH  
              Started by Christopher_R, Today, 12:29 AM
              1 response
              14 views
              0 likes
              Last Post NinjaTrader_LuisH  
              Started by chartchart, 05-19-2021, 04:14 PM
              3 responses
              577 views
              1 like
              Last Post NinjaTrader_Gaby  
              Started by bsbisme, Yesterday, 02:08 PM
              1 response
              15 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Working...
              X