www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.dwt - SelectionListener called twice

reply Mitja <mitja_ursic yahoo.com> writes:
Content-Type: text/plain

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?
Nov 13 2009
parent reply Mitja <mitja_ursic yahoo.com> writes:
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?
 

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; }
Nov 13 2009
parent reply Frank Benoit <keinfarbton googlemail.com> writes:
Windows/Linux/Mac ?
Please provide more information.
I tried it on winxp with no problem.
Nov 14 2009
parent Mitja <mitja_ursic yahoo.com> writes:
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.

Nov 16 2009