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 Rapine Heihei, 04-23-2024, 07:51 PM
      2 responses
      30 views
      0 likes
      Last Post Max238
      by Max238
       
      Started by Shansen, 08-30-2019, 10:18 PM
      24 responses
      943 views
      0 likes
      Last Post spwizard  
      Started by Max238, Today, 01:28 AM
      0 responses
      9 views
      0 likes
      Last Post Max238
      by Max238
       
      Started by rocketman7, Today, 01:00 AM
      0 responses
      5 views
      0 likes
      Last Post rocketman7  
      Started by wzgy0920, 04-20-2024, 06:09 PM
      2 responses
      28 views
      0 likes
      Last Post wzgy0920  
      Working...
      X