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

How to set Button Hover/MouseEnter background colour?

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

    How to set Button Hover/MouseEnter background colour?

    Hello

    I am adding custom buttons to the toolbar and trying to match existing buttons mouse over/enter colors behavior.
    There seems to be a native background hover color I cant find how to override...

    Click image for larger version

Name:	MouseOverGIFF.gif
Views:	528
Size:	31.6 KB
ID:	1121406

    I have set the:

    btnStyle.Setters.Add(new Setter(Button.BackgroundProperty, Brushes.DimGray));

    But can not find Button background color on MouseEnter property. So I also tried to override the desired properties using the Button.MouseEnter / MouseExit callbacks:

    Click image for larger version

Name:	MouseOverCallbacks.gif
Views:	488
Size:	14.5 KB
ID:	1121407
    But as you can see in the above GIF there is a background color for the hover state which is just doing its own thing?

    1) How do I control the Button.Style on mouse hover/enter?
    2) Specifically I am just trying to make the text color brighter and keep all other background colors the same?

    Thanks

    #2
    Hello, thanks for your post.

    You can disable the blue highlighting with the UseOverflowMenu. I attached an example here. As for the styling of the button that would take more research. I found this publicly available post on the subject:
    https://stackoverflow.com/questions/...-mouse-is-over

    Please let me know if I can assist any further.
    Attached Files
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Thanks Chris

      Sorry I should have clarified these buttons are being added to a Chart not the Control Panel.
      So as I understand it I have to use a custom Indicator. The documentation lead me to believe extending AddOn is for ones that require a window. Your provided file the UseOverflowMenu property isn't accessible as the constructor isn't executed until a window opens. I have not been able to find how an AddOn can be added to a Chart. If that is possible? I also don't need to launch a window. Just ad buttons to the Chart.

      Is my under standing correct that Indicators are the correct API for that?

      So while an Indicator does not have a UseOverflowMenu property. I did find that with a break point in the indicator's: State == State.Realtime constructor
      I can find the parent Chart which does have that property which I can reach via the ChartControl.Dispatcher.InvokeAsync:
      Code:
      else if (State == State.Realtime){
          if (ChartControl != null && !isLoaded) {
      
              ChartControl.Dispatcher.InvokeAsync((Action)(() => {
      
                  chartWindow = Window.GetWindow(this.ChartControl.Parent) as Chart;
                  if ( chartWindow != null ){
                      chartWindow.UseOverflowMenu = true; // <------ [U]BUT UseOverflowMenu [SIZE=16px][B]comes in already set to true[/B][/SIZE]. This is redundant?[/U]
                  }
                  AddButtons();
      })); } }
      So UseOverflowMenu being false doesn't seem to be the cause of the Blue mouse over background?

      Is this dealt with differently in an Indicator?

      Thanks for your help.
      Last edited by SmartArtsStudio; 10-07-2020, 09:03 AM.

      Comment


        #4
        Oh I also tried flipping
        chartWindow.UseOverflowMenu = false
        It does change something, because the buttons look nicer, and it has a nicer transition to blue
        But it also changes the mouse over functionality for every icon on, adding a border on mouse over.
        That is obviously not NT8 native intention.

        So UseOverflowMenu has a blue background on mouse over whether its set to 'true' or 'false'

        Comment


          #5
          Hello, thanks for your reply.

          Please have a look at the example on this thread named "ChartTraderCustomButtonsExample_NT8"

          Hello All, Moving forward this will be maintained in the help guide reference samples and no longer maintained on the forum. Creating Chart WPF (UI) Modifications from an Indicator - https://ninjatrader.com/support/help...ui)-modifi.htm (https://ninjatrader.com/support/helpGuides/nt8/creating-chart-wpf-(ui)-modifi.htm) I've


          This example adds buttons to the chart trader grid and copies the button style from an existing button style:

          Style basicButtonStyle = Application.Current.FindResource("BasicEntryButton ") as Style;

          That will remove the blue highlight as well.

          Please let me know if you have any questions on this material.
          Chris L.NinjaTrader Customer Service

          Comment


            #6
            Thanks Chris.

            Those additional links are also going to be appreciated. The code for the button definitely works. I would really like to know how it works. Which property turns it off so I can also style my own buttons. I have looked through the basicButtonStyle object returned but I am a little surprised I can not find any style properties on it at runtime I figure that must be because Styles are sealed once created?

            I could not find the "BasicEntryButton" Style object defined in the public NinjaScript code base. Are you able to provide it so I can figure it out from there?

            Thanks
            Daniel

            Comment


              #7
              Hello SmartArtsStudio, thanks for your reply.

              I will need to research how WPF styling works. I'll follow up on the subject when I have more information.

              Thanks in advance for your patience.
              Chris L.NinjaTrader Customer Service

              Comment


                #8
                Hello Daniel, thanks for waiting.

                I found that the styles are compiled into the NinjaTrader DLL libraries, so we will not be able to provide any more details on the subject. Application.Current.FindResource can be used to mimic the resources we have already created.

                Please let me know if I can assist any further.
                Chris L.NinjaTrader Customer Service

                Comment


                  #9
                  Hi Chris

                  Yes I was hoping you might have access to the pre-compiled dll source.

                  Thanks for having looked into it, its appreciated.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by geddyisodin, Today, 05:20 AM
                  0 responses
                  1 view
                  0 likes
                  Last Post geddyisodin  
                  Started by JonesJoker, 04-22-2024, 12:23 PM
                  6 responses
                  32 views
                  0 likes
                  Last Post JonesJoker  
                  Started by GussJ, 03-04-2020, 03:11 PM
                  12 responses
                  3,239 views
                  0 likes
                  Last Post Leafcutter  
                  Started by AveryFlynn, Today, 04:57 AM
                  0 responses
                  5 views
                  0 likes
                  Last Post AveryFlynn  
                  Started by RubenCazorla, 08-30-2022, 06:36 AM
                  3 responses
                  79 views
                  0 likes
                  Last Post PaulMohn  
                  Working...
                  X