Popup menu on DateTime [message #689744] |
Tue, 28 June 2011 08:43 |
|
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 |
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.03262 seconds