Thread overview | ||||||
---|---|---|---|---|---|---|
|
November 13, 2009 SelectionListener called twice | ||||
---|---|---|---|---|
| ||||
Attachments: | SelectionListener for calendar is called twice after button has been pressed. You have to select other than today's date first. I want for the listener to trigger only once. What am I doing wrong? |
November 13, 2009 Re: SelectionListener called twice | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mitja | Mitja Wrote: > SelectionListener for calendar is called twice after button has been pressed. You have to select other than today's date first. > I want for the listener to trigger only once. > > What am I doing wrong? > module datetime; import Clock = tango.time.Clock; import tango.io.Stdout; import dwt.DWT; import dwt.widgets.Button; import dwt.widgets.Shell; import dwt.widgets.Display; import dwt.widgets.DateTime; import dwt.layout.GridLayout; import dwt.widgets.Listener; import dwt.widgets.Event; import dwt.events.SelectionAdapter; import dwt.events.SelectionEvent; void main() { Display display = new Display; Shell shell = new Shell(display); shell.setLayout(new GridLayout(1, false)); DateTime calendar = new DateTime(shell, DWT.CALENDAR); calendar.addSelectionListener(new class(calendar) SelectionAdapter { DateTime cal; this(DateTime cal) { this.cal = calendar; } public void widgetSelected(SelectionEvent e) { Stdout("selected").newline; } }); Button b = new Button(shell, DWT.NONE); b.setText("TODAY"); b.addListener(DWT.Selection, new class(calendar) Listener { DateTime cal; this(DateTime d) { this.cal = calendar; } public void handleEvent(Event event) { auto date = Clock.Clock().toDate.date; this.cal.setDate(date.year, date.month - 1, date.day); } }); shell.open; while(!shell.isDisposed) { if(!display.readAndDispatch) display.sleep; } display.dispose; } |
November 14, 2009 Re: SelectionListener called twice | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mitja | Windows/Linux/Mac ? Please provide more information. I tried it on winxp with no problem. |
November 16, 2009 Re: SelectionListener called twice | ||||
---|---|---|---|---|
| ||||
Posted in reply to Frank Benoit | Linux 2.6.18-5-686 Debian Lenny
DMD v1.033
Tango 0.99.7
DWT 3.4-1
Frank Benoit Wrote:
> Windows/Linux/Mac ?
> Please provide more information.
> I tried it on winxp with no problem.
|
Copyright © 1999-2021 by the D Language Foundation