Bug 246843 - Menu#setVisible(..) should show the menu while handling mouseDown event on button
Summary: Menu#setVisible(..) should show the menu while handling mouseDown event on bu...
Status: RESOLVED WORKSFORME
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.5   Edit
Hardware: PC Mac OS X
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Silenio Quarti CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords: triaged
Depends on:
Blocks: 297268
  Show dependency tree
 
Reported: 2008-09-10 06:26 EDT by Markus Keller CLA
Modified: 2019-09-02 15:11 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2008-09-10 06:26:20 EDT
I20080909-1121, carbon

Menu#setVisible(..) should immediately show the menu, also while handling mouseDown event on a button.

Steps:
- run the snippet below
- press left mouse button down on the button and hold it down

=> expected (works fine on WinXP): Menu should show up. Moving the mouse to the menu item and releasing it there should execute the menu item.

=> was: Popup menu only shows up after mouseUp.

This can be seen in Eclipse for the view menu button, the menu buttons in the Quick Outline, Open Resource dialog, etc.


public class SnippetButtonMouseDown {
    public static void main(String[] args) {
        final Display display= new Display();
        final Shell shell= new Shell(display, SWT.DIALOG_TRIM);
        GridLayout shellLayout= new GridLayout(2, false);
        shell.setLayout(shellLayout);
        
        final Button button= new Button(shell, SWT.PUSH);
        button.setText("Button");
        button.addMouseListener(new MouseAdapter() {
            public void mouseDown(org.eclipse.swt.events.MouseEvent e) {
                Menu menu= new Menu(button);
                MenuItem item= new MenuItem(menu, SWT.PUSH);
                item.setText("Item");
                item.addSelectionListener(new SelectionAdapter() {
                    public void widgetSelected(SelectionEvent e) {
                        System.out.println("selected");
                    }
                });
                menu.setLocation(button.toDisplay(0, button.getSize().y));
                menu.setVisible(true);
            }
        });
        
        shell.pack();
        shell.open();
        while (!shell.isDisposed()) {
            if (!display.readAndDispatch())
                display.sleep();
        }
        display.dispose();
    }
}
Comment 1 Markus Keller CLA 2008-09-10 06:31:05 EDT
Adding
		display.runPopups ();

at the end of Menu#setVisible(boolean) makes click-drag-release work, but leaves the menu open after the user has selected the menu item.
Comment 2 Silenio Quarti CLA 2008-10-29 10:40:18 EDT
Might be a duplicate of bug#216062.
Comment 3 Markus Keller CLA 2009-05-18 11:46:05 EDT
> Might be a duplicate of bug#216062.

Nope, that one works for me in I20090515-1143 Cocoa, but menu.setVisible(true) in the mouseDown(..) handler still doesn't show the menu immediately.
Comment 4 Silenio Quarti CLA 2012-06-21 12:01:13 EDT
Also happens on cocoa.
Comment 5 Eclipse Genie CLA 2018-10-23 12:04:41 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 6 Lars Vogel CLA 2019-09-02 15:09:02 EDT
This bug has been marked as stalebug a while ago without any further interaction.

If this report is still relevant for the current release, please reopen and remove the stalebug whiteboard flag.
Comment 7 Lars Vogel CLA 2019-09-02 15:11:50 EDT
This bug was marked as stalebug a while ago. Marking as worksforme.

If this report is still relevant for the current release, please reopen and remove the stalebug whiteboard tag.