Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NT8 - Where to define MouseEvents

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

    NT8 - Where to define MouseEvents

    Hello,

    I would like to use MouseEvents like these:

    ChartPanel.MouseLeftButtonUp += new MouseButtonEventHandler(myMouseEvents);

    ChartPanel.MouseLeftButtonUp -= midasMouseEvents;

    Where do i have to define them?

    Currently they are located in State.Configure and State.Terminated but i get some errors in the Ouput:

    Error on calling 'OnStateChange' method: Object reference not set to an instance of an object.

    Thank you,
    Mike

    #2
    Hello,

    Thank you for the question.

    In general the error Object reference not set to an instance of an object indicates that in one of these states, the object you are trying to use is null.

    This could potentially be caused by the nature of the states in combination with not checking if the object is null.

    To start you can try adding a null check, this should resovle the error you are getting.


    Code:
    if(ChartPanel != null)
    {
       // execute code
    }
    Also you may want to move this logic to State.Historical, ChartControl and its sub objects should only be accessed from State.Historical and after, this likely would include the charts panel as well.

    I look forward to being of further assistance.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    152 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    87 views
    1 like
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    131 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    127 views
    1 like
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    106 views
    0 likes
    Last Post CarlTrading  
    Working...
    X