|
|
Re: Popup menu from menu item, similar to IE Favorites popup [message #517535 is a reply to message #517482] |
Mon, 01 March 2010 08:52 |
Vijay Raj Messages: 608 Registered: July 2009 |
Senior Member |
|
|
I saw this type of behavior in bookmarks menu in mozilla and favorites menu in IE....
Yes i too agree, i think it would be a drop down menu kind of thing with a shell which looks like a menu...
For start you can try this..
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Shell;
public class MenuInMenu {
public static void main(String[] args) {
Display display = new Display();
final Shell shell = new Shell(display);
shell.setSize(400,300);
Menu m = new Menu(shell, SWT.BAR);
MenuItem file = new MenuItem(m, SWT.CASCADE);
file.setText("File");
file.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
Shell s = new Shell(shell,SWT.None);
Rectangle bounds = shell.getBounds();
s.setBounds(new Rectangle(bounds.x, bounds.y+50, 100, 150));
s.open();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
// TODO Auto-generated method stub
}
});
shell.setMenuBar(m);
shell.open ();
while (!shell.isDisposed()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
}
Note you have to position the opened shell properly and should handle closing of the shell also...
add any control to the shell hence popups to them...
---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay
[Updated on: Mon, 01 March 2010 09:27] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.02235 seconds