Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Getting compile button of NinjaScript Editor in Addon

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

    Getting compile button of NinjaScript Editor in Addon

    Hello,
    I'm trying to close all my addon windows after clicking on compile button from ninja script editor. I used the following code to get the button from the code but it's not working:

    Code:
    NinjaTrader.Gui.NinjaScript.Editor.EditorView ev = window as NinjaTrader.Gui.NinjaScript.Editor.EditorView;
    if (ev!=null)
    {
    Button compile =ev.FindFirst("Compile") as Button;
    
    }
    Actually i get the following error:

    System.InvalidOperationException: ''NinjaTrader.Gui.NinjaScript.Editor.ScriptItem' is not a Visual or Visual3D.'

    Could you please help?
    Best regards,
    Last edited by zakoun; 02-10-2021, 06:12 PM.

    #2
    Hello zakoun,

    You could write an addon for that purpose or also just put some logic in your existing addon to close its self when terminated.

    When you compile an addon it is terminated and will run its State.Active again, thats why you will see the menu item flash if you look in the control center. You could at that point loop through the open windows and close any existing windows of your type.

    You can loop through the NinjaTrader.Core.Globals.AllWindows collection of windows to find any of your windows.

    If you were doing this from the addon its self that code would go in the base addon class in its State.Terminated, from our sample thats the: public class AddOnFramework : AddOnBase.


    The code could look like the following:

    Code:
    if (State == State.Terminated)
    {
           foreach(NTWindow window in NinjaTrader.Core.Globals.AllWindows)
          {
             window.Dispatcher.InvokeAsync(() =>{
             if(window is AddOnFrameworkWindow)
             {
                window.Close();
             }
          });
       }
    }

    I look forward to being of further assistance.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    596 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    343 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    103 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    556 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    554 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X