File tree 1 file changed +37
-0
lines changed
1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -268,6 +268,43 @@ where
268
268
event_status
269
269
}
270
270
}
271
+ Event :: Mouse ( mouse:: Event :: WheelScrolled {
272
+ delta : mouse:: ScrollDelta :: Lines { y, .. } ,
273
+ } ) if layout. bounds ( ) . contains ( cursor_position)
274
+ && !* self . is_open =>
275
+ {
276
+ fn find_next < ' a , T : PartialEq > (
277
+ selected : & ' a T ,
278
+ mut options : impl Iterator < Item = & ' a T > ,
279
+ ) -> Option < & ' a T > {
280
+ let _ = options. find ( |& option| option == selected) ;
281
+
282
+ options. next ( )
283
+ }
284
+
285
+ let next_option = if y < 0.0 {
286
+ if let Some ( selected) = self . selected . as_ref ( ) {
287
+ find_next ( selected, self . options . iter ( ) )
288
+ } else {
289
+ self . options . first ( )
290
+ }
291
+ } else if y > 0.0 {
292
+ if let Some ( selected) = self . selected . as_ref ( ) {
293
+ find_next ( selected, self . options . iter ( ) . rev ( ) )
294
+ } else {
295
+ self . options . last ( )
296
+ }
297
+ } else {
298
+ None
299
+ } ;
300
+
301
+ if let Some ( next_option) = next_option {
302
+ messages. push ( ( self . on_selected ) ( next_option. clone ( ) ) ) ;
303
+ }
304
+
305
+ return event:: Status :: Captured ;
306
+ }
307
+
271
308
_ => event:: Status :: Ignored ,
272
309
}
273
310
}
You can’t perform that action at this time.
0 commit comments