On Fri, 22 Jan 2021 11:02:29 GMT, Robert Lichtenberger <[email protected]>
wrote:
>> While trying to come up with a good documentation I've detected a real
>> change in behaviour in connection with the NodeOrientation of the anchor
>> node.
>> Although this has never been documented, when NodeOrientation.RIGHT_TO_LEFT
>> is set, the context menu was right-aligned for Side=TOP and Side=BOTTOM.
>> Since I assume we don't want to change this behaviour I would now document
>> it and adapt my patch accordingly. I've already written a test case like
>> this:
>> @Test public void test_position_withOrientation() throws
>> InterruptedException {
>> ContextMenu cm = createContextMenu(false);
>> anchorBtn.setNodeOrientation(NodeOrientation.RIGHT_TO_LEFT);
>> cm.show(anchorBtn, Side.TOP, 0, 0);
>>
>> Bounds anchorBounds =
>> anchorBtn.localToScreen(anchorBtn.getLayoutBounds());
>> Node cmNode = cm.getScene().getRoot();
>> Bounds cmBounds =
>> cm.getScene().getRoot().localToScreen(cmNode.getLayoutBounds());
>>
>> assertEquals(anchorBounds.getMaxX(), cmBounds.getMaxX(), 0.0);
>> assertEquals(anchorBounds.getMinY(), cmBounds.getMaxY(), 0.0);
>> anchorBtn.setNodeOrientation(NodeOrientation.LEFT_TO_RIGHT);
>> }
>> which passes with the old implementation but (currently) fails with the new
>> implementation.
>
> Oh wow. Further experimentation has shown, that if
> NodeOrientation.RIGHT_TO_LEFT is used on the anchor, then Side.LEFT used to
> make the menu appear on the **right** hand side and Side.RIGHT used to make
> the menu appear on the **left** hand side of the button, which really
> surprises me, since I didn't expect the side parameter to be relative.
Ok, I just pushed all the changes necessary to keep the old behaviour for
right-to-left node orientation.
If you would rather have the behaviour changed (it doesn't seem very intuitive
to me...) just tell me and I can change the implementation / tests.
-------------
PR: https://git.openjdk.java.net/jfx/pull/383