Announcement

Collapse
No announcement yet.

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, 06: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 sidlercom80, Today, 02:40 AM
      0 responses
      3 views
      0 likes
      Last Post sidlercom80  
      Started by b16_aln, Today, 01:52 AM
      0 responses
      7 views
      0 likes
      Last Post b16_aln
      by b16_aln
       
      Started by junkone, Yesterday, 08:55 PM
      1 response
      8 views
      0 likes
      Last Post NinjaTrader_Jason  
      Started by adaeiqendqw, 01-16-2021, 02:56 AM
      1 response
      15 views
      0 likes
      Last Post NinjaTrader_Jason  
      Started by [email protected], Yesterday, 06:10 PM
      5 responses
      16 views
      0 likes
      Last Post NinjaTrader_ChrisSch  
      Working...
      X