5 Replies Latest reply on Jan 18, 2013 2:46 PM by David Grieve-Oracle

    Hover color on ContextMenu

      How do i change the hover color used on a menu item in a ContextMenu using setStyle() or getStyleClass().add()

      Actually I'd like to remove / switch off the hover color. I suppose this would be done by making the hover color the same as the normal background color or is there another / better way ?

        • 1. Re: Hover color on ContextMenu
          I've tested this out, but seems not to work..

          The normal way should be something like this:
             -fx-background-color: blue;
             -fx-background-color: red;
          1 person found this helpful
          • 2. Re: Hover color on ContextMenu
            Thanks for replying.

            I don't want to do this on a global app scale though, just on this one particular ContextMenu's custom menu item.

            Would the following css and code then be correct ?
            .nohover:hover { -fx-background-color: transparent; }
            Edited by: jugen on Jan 16, 2013 1:11 AM
            • 3. Re: Hover color on ContextMenu
              At first look this seems correct:

              Don't forget to add your stylesheet to your scene like this:
              Wath you can also do if it's for 1 particular ContextMenu, is to work with an id.
              so like this:
              In the myStyleSheet.css file:
                  -fx-background-color: transparent;
              1 person found this helpful
              • 4. Re: Hover color on ContextMenu
                Mmmm, so i tried this with mixed results ?
                .nohover:hover { -fx-background-color: transparent; }
                The above indeed produces the desired effect when the mouse is ON the menu item then the default caspian blue is not visible.

                However ContextMenu has a thin "border" and when the mouse crosses that border area then the menu item highlights in blue ?!

                Trying the above code on the ContextMenu makes it become transparent - so then the menu item hangs in the air.
                So I tried -fx-base and -fx-background instead of transparent but the blue highlight persists !?

                Any ideas anybody ?