Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebPopupMenu resets preferred display position after it becomes visible #603

Closed
mgarin opened this issue Jan 9, 2020 · 1 comment
Closed

Comments

@mgarin
Copy link
Owner

mgarin commented Jan 9, 2020

Originally reported by @husker-dev via email.

Here is a code example displaying the issue:

public class MenuTest
{
    public static void main ( final String[] args )
    {
        SwingTest.run ( new Runnable ()
        {
            @Override
            public void run ()
            {
                final WebPopupMenu menu = new WebPopupMenu ();
                menu.setPopupMenuWay ( PopupMenuWay.belowEnd );
                menu.add ( new WebMenuItem ( "Item" ) );

                final WebButton button = new WebButton ( "Show menu" );
                button.addActionListener ( new ActionListener ()
                {
                    @Override
                    public void actionPerformed ( final ActionEvent e )
                    {
                        // menu.setPopupMenuWay ( PopupMenuWay.belowEnd );
                        menu.show ( button, -button.getWidth () / 2, button.getHeight () );
                    }
                } );

                TestFrame.show ( button );
            }
        } );
    }
}

If the commented line of code is uncommented - menu will always be displayed correctly.

This technically isn't a bug because originaly I intended PopupMenuWay (probably should be renamed in future to something better as well) to be a one-time use setting. And that is how it basically works in current version.

Although this is surely not convenient and, realistically, you would rarely need to change this setting in actual use cases. So it is worth preserving it over multiple displays of the same popup menu.

@mgarin mgarin added this to the v1.2.12 milestone Jan 9, 2020
@mgarin mgarin self-assigned this Jan 9, 2020
@mgarin mgarin added this to Planned in v1.2.12 via automation Jan 9, 2020
@mgarin mgarin moved this from Planned to In Progress in v1.2.12 Jan 9, 2020
mgarin added a commit that referenced this issue Jan 9, 2020
- WebPopupMenuUI.java - Setting `popupMenuWay` will now be preserved across multiple popup menu displays
@mgarin
Copy link
Owner Author

mgarin commented Jan 9, 2020

I've changed the code to preserve the setting.
This change will shortly be available in v1.2.12 snapshot artifacts.

@mgarin mgarin closed this as completed Jan 9, 2020
v1.2.12 automation moved this from In Progress to Completed Jan 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
v1.2.12
  
Completed
Development

No branches or pull requests

1 participant