Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Momentaliry Disabling Scroll Bar

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

    Momentaliry Disabling Scroll Bar

    Hello,

    The template switcher is basically finished. Still have to convert the types to dynamic, but the core logic itself was coded with dynamic in mind (as in parsing enums at run time instead of calling the NinjaTrader namespaces directly, etc.). Anyways, a feature I would like to include would be the use of the scroll bar as a means to switch templates. That part is done. However, when using the scroll wheel it moves the chart.

    Would it be possible to momentarily disable the scroll bar? Not sure if that's possible so I tried to simulate the scroll wheel. It ends up scrolling forever.

    The infinite scrolling problem is more of a C# problem. Wanted to see if NinjaTrader has a quick solution before diving deeper into my solution.

    Working Normally

    Click image for larger version  Name:	9t9OH9U.gif Views:	0 Size:	839.9 KB ID:	1129453
    Infinite Scrolling

    Click image for larger version  Name:	qtgUTnC.gif Views:	0 Size:	63.0 KB ID:	1129454

    Thanks
    Last edited by Unsuitable; 11-25-2020, 07:32 PM.
    Unsuitable
    NinjaTrader Ecosystem Vendor - Ocean Trading Indicators

    #2
    Hello Unsuitable, thanks for writing in. There would be no supported way to disable the default mouse behavior for a chart, unfortunately.

    Please let me know if I may provide any further information.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Hello ChrisL,

      I tried looking for a way to disable scrolling in ChartControl but there's none as you mentioned. Turns out the reason it's sending out infinite scrolling is that when it simulates a scroll movement (to cancel out the movement of the chart), that sends out another mouse scroll wheel mouse listener thus creating an infinite loop of scrolling. I tried to remove the event listener and re-add after the scroll method is called, but the re-subscribing of the event listener happens before the simulated scroll finishes. I also tried to store a bool, isScrolling, and set that to false after the object switches templates. Again, that process finishes before the simulated scrolling does and creates an infinite loop of scrolling.

      Code:
      [DllImport("User32.dll")]
      public static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, IntPtr dwExtraInfo);
      
      private void MouseWheelEvent(object sender, MouseWheelEventArgs e)
      {
      
        if (!isSomethingSelected & storedDrawObjectSlected != null)
        {
          ChartControl.MouseWheel -= MouseWheelEvent;
          storedDrawObjectSlected = null;
          isSomethingSelected = false;
          return;
        }
      
        ChartControl.MouseWheel -= MouseWheelEvent;
      
        if (e.Delta > 0)
        {
          changeIndexBy = 1;
          ChangeChartObjectSetting(storedDrawObjectSlected);
          mouse_event(MOUSEEVENTF_WHEEL, 0, 0, -120, (IntPtr) 0);
          ChartControl.MouseWheel += MouseWheelEvent;
          return;
        }
        else if (e.Delta < 0 )
        {
          changeIndexBy = -1;
          ChangeChartObjectSetting(storedDrawObjectSlected);
          mouse_event(MOUSEEVENTF_WHEEL, 0, 0, 120, (IntPtr) 0);
          ChartControl.MouseWheel += MouseWheelEvent;
          return;
        }
      }
      This is a C# problem and I don't expect NT to support it. Perhaps if someone knows a solution.
      Unsuitable
      NinjaTrader Ecosystem Vendor - Ocean Trading Indicators

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by mattbsea, Today, 05:44 PM
      0 responses
      4 views
      0 likes
      Last Post mattbsea  
      Started by RideMe, 04-07-2024, 04:54 PM
      6 responses
      31 views
      0 likes
      Last Post RideMe
      by RideMe
       
      Started by tkaboris, Today, 05:13 PM
      0 responses
      2 views
      0 likes
      Last Post tkaboris  
      Started by GussJ, 03-04-2020, 03:11 PM
      16 responses
      3,282 views
      0 likes
      Last Post Leafcutter  
      Started by WHICKED, Today, 12:45 PM
      2 responses
      20 views
      0 likes
      Last Post WHICKED
      by WHICKED
       
      Working...
      X