1

I've been working on a Button extending class that when left-clicked on displays a stay-open popup menu (ContextMenu object) on a configurable side/corner of the button. The constructor takes an enumerated value like NORTH_LEFT that indicates the side of the button where it gets shown and which edges on both the button and popup are aligned. In other words the 2 should always show in an L shape combo, not a T shape.

So when I want to do something like EAST_BOTTOM where the bottom edges of both button and popup should align, I figured something like this would work:

PopupMenu.show(this, Side.RIGHT, 0, this.getHeight() - PopupMenu.getHeight());

But what I get is a Popup that appears much higher up then it should. That's because the PopupMenu.getHeight() call is returning a larger value then expected. I suspect because it is including the large shadow border in its dimensions. I've noticed that this semi-visible border also extends over my button a bit and prevents mouse clicks from registering on the edge of the button near the menu. So I have multiple reasons to want a border of 0 width.

I assume there is a way to do it via CSS. I've tried setting -fx-background-insets and -fx-padding to 0 but neither seems to make a difference. Any other suggestions?

Mike O
  • 291
  • 1
  • 4
  • 17
  • Have you checked [this](http://stackoverflow.com/a/25437004/3956070)? Is the same issue? – José Pereda Jul 10 '15 at 17:47
  • I did see that and I've tried playing around with .root.popup {} settings but nothing I've done so far has had any impact on the border's size. – Mike O Jul 10 '15 at 18:49
  • A picture will help understanding your problem... – José Pereda Jul 10 '15 at 18:51
  • There's a picture with a contextmenu being shown on linked page below. Note the dark shadow effects around the edges of the menu. That border seems to be part of the getWidth/Height calculations for the menu. So I want to remove or minimize the shadow border to 0 so I just have a plain, undecorated box for the menu. http://stackoverflow.com/questions/16402089/javafx-adding-context-menu-on-line-chart – Mike O Jul 10 '15 at 19:43
  • 2
    What you see on the picture is a `DropShadow` effect. It's easy to remove: `-fx-effect: null;` will do. – José Pereda Jul 10 '15 at 19:46
  • Yes, that did it! Thank you. I did have the thought to try that earlier but Netbeans flagged the null in my css as an unexpected character, so I deleted it and never actually tried it till now. – Mike O Jul 10 '15 at 19:53

1 Answers1

3

The solution is to add -fx-effect: null; to your CSS for the ContextMenu. This removes the dropshadow effect that is the modena.css default for ContextMenus. Once I did that I was able to correctly place my menu wherever I needed it to go.

Credit for this working answer goes to José Pereda - we worked it out in the comments above.

Mike O
  • 291
  • 1
  • 4
  • 17