comparison dynamin/gui/radio_button.d @ 48:41b141453b8e

Fix crash in RadioButton.whenKeyDown()
author Jordan Miner <jminer7@gmail.com>
date Tue, 04 Aug 2009 20:31:15 -0500
parents 6b264c92da34
children 6e33b00595e9
comparison
equal deleted inserted replaced
47:41b76c218851 48:41b141453b8e
64 } 64 }
65 override void whenKeyDown(KeyEventArgs e) { 65 override void whenKeyDown(KeyEventArgs e) {
66 // TODO: when GetTopLevel() is changed to return NativeControl, 66 // TODO: when GetTopLevel() is changed to return NativeControl,
67 // update this 67 // update this
68 int index; 68 int index;
69 RadioButton[] radios = collectGroup(index);
70 if(radios is null)
71 return;
72 if(e.key == Key.Down || e.key == Key.Right) { 69 if(e.key == Key.Down || e.key == Key.Right) {
70 RadioButton[] radios = collectGroup(index);
71 if(radios is null)
72 return;
73 if(++index >= radios.length) 73 if(++index >= radios.length)
74 index = 0; 74 index = 0;
75 radios[index].clicked(new EventArgs);
76 e.stopped = true;
75 } else if(e.key == Key.Up || e.key == Key.Left) { 77 } else if(e.key == Key.Up || e.key == Key.Left) {
78 RadioButton[] radios = collectGroup(index);
79 if(radios is null)
80 return;
76 if(--index < 0) 81 if(--index < 0)
77 index = radios.length-1; 82 index = radios.length-1;
83 radios[index].clicked(new EventArgs);
84 e.stopped = true;
78 } 85 }
79 radios[index].clicked(new EventArgs);
80 } 86 }
81 override void whenPainting(PaintingEventArgs e) { 87 override void whenPainting(PaintingEventArgs e) {
82 Theme.current.RadioButton_paint(this, e.graphics); 88 Theme.current.RadioButton_paint(this, e.graphics);
83 } 89 }
84 override void whenClicked(EventArgs e) { 90 override void whenClicked(EventArgs e) {