Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Popup menu on DateTime
Popup menu on DateTime [message #689744] Tue, 28 June 2011 08:43 Go to next message
Elvis Dominguez is currently offline Elvis DominguezFriend
Messages: 52
Registered: July 2009
Location: Switzerland
Member
Hi,

I'd like to add a popup menu on a DateTime widget.
The popup contains a single item that resets the value to a standard one.

I have tried as follows:

DateTime dt = new DateTime(parent, style);
Menu menu = new Menu(dt.getParent().getShell(), SWT.POP_UP);
MenuItem mi = new MenuItem(menu, SWT.PUSH);
mi.setText("Reset");
dt.setMenu(popup);

But the popup menu isn't show, the standard OS's provided one raises.
The same code runs fine on a Text widget.

--
kindly Elvis Dominguez
Re: Popup menu on DateTime [message #689746 is a reply to message #689744] Tue, 28 June 2011 08:54 Go to previous message
Elvis Dominguez is currently offline Elvis DominguezFriend
Messages: 52
Registered: July 2009
Location: Switzerland
Member
I have solved my issue.
The problem is that DateTime is a composite that contains a text field
and other controls.
When I call DateTime.setMenu() I set the menu to the composite but not on
the containing field.

I edited my method as follows:
DateTime dt = new DateTime(parent, style);
Menu menu = new Menu(dt.getParent().getShell(), SWT.POP_UP);
MenuItem mi = new MenuItem(menu, SWT.PUSH);
mi.setText("Reset");
for( Control each : dt.getChildren())
{
if( each instanceof Text)
each.setMenu(popup);
}

Should i file a bug? Where?

On Tue, 28 Jun 2011 08:43:44 +0000, Elvis Dominguez wrote:

> Hi,
>
> I'd like to add a popup menu on a DateTime widget. The popup contains a
> single item that resets the value to a standard one.
>
> I have tried as follows:
>
> DateTime dt = new DateTime(parent, style); Menu menu = new
> Menu(dt.getParent().getShell(), SWT.POP_UP); MenuItem mi = new
> MenuItem(menu, SWT.PUSH); mi.setText("Reset");
> dt.setMenu(popup);
>
> But the popup menu isn't show, the standard OS's provided one raises.
> The same code runs fine on a Text widget.





--
kindly Elvis Dominguez
Previous Topic:Scroll bar not behaving as expected in a tabbed properties view.
Next Topic:StackLayout Problem
Goto Forum:
  


Current Time: Thu Mar 28 17:54:07 GMT 2024

Powered by FUDForum. Page generated in 0.02337 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top