@@ -304,14 +304,13 @@ pub enum Action {
304
304
/// Requires [`ActionRequest::data`] to be set to [`ActionData::Value`].
305
305
ReplaceSelectedText ,
306
306
307
- // Scrolls by approximately one screen in a specific direction.
308
- // TBD: Do we need a doc comment on each of the values below?
309
- // Or does this awkwardness suggest a refactor?
310
- ScrollBackward ,
307
+ /// Scroll down by the specified unit.
311
308
ScrollDown ,
312
- ScrollForward ,
309
+ /// Scroll left by the specified unit.
313
310
ScrollLeft ,
311
+ /// Scroll right by the specified unit.
314
312
ScrollRight ,
313
+ /// Scroll up by the specified unit.
315
314
ScrollUp ,
316
315
317
316
/// Scroll any scrollable containers to make the target object visible
@@ -365,19 +364,17 @@ impl Action {
365
364
8 => Some ( Action :: HideTooltip ) ,
366
365
9 => Some ( Action :: ShowTooltip ) ,
367
366
10 => Some ( Action :: ReplaceSelectedText ) ,
368
- 11 => Some ( Action :: ScrollBackward ) ,
369
- 12 => Some ( Action :: ScrollDown ) ,
370
- 13 => Some ( Action :: ScrollForward ) ,
371
- 14 => Some ( Action :: ScrollLeft ) ,
372
- 15 => Some ( Action :: ScrollRight ) ,
373
- 16 => Some ( Action :: ScrollUp ) ,
374
- 17 => Some ( Action :: ScrollIntoView ) ,
375
- 18 => Some ( Action :: ScrollToPoint ) ,
376
- 19 => Some ( Action :: SetScrollOffset ) ,
377
- 20 => Some ( Action :: SetTextSelection ) ,
378
- 21 => Some ( Action :: SetSequentialFocusNavigationStartingPoint ) ,
379
- 22 => Some ( Action :: SetValue ) ,
380
- 23 => Some ( Action :: ShowContextMenu ) ,
367
+ 11 => Some ( Action :: ScrollDown ) ,
368
+ 12 => Some ( Action :: ScrollLeft ) ,
369
+ 13 => Some ( Action :: ScrollRight ) ,
370
+ 14 => Some ( Action :: ScrollUp ) ,
371
+ 15 => Some ( Action :: ScrollIntoView ) ,
372
+ 16 => Some ( Action :: ScrollToPoint ) ,
373
+ 17 => Some ( Action :: SetScrollOffset ) ,
374
+ 18 => Some ( Action :: SetTextSelection ) ,
375
+ 19 => Some ( Action :: SetSequentialFocusNavigationStartingPoint ) ,
376
+ 20 => Some ( Action :: SetValue ) ,
377
+ 21 => Some ( Action :: ShowContextMenu ) ,
381
378
_ => None ,
382
379
}
383
380
}
@@ -2600,6 +2597,26 @@ pub struct TreeUpdate {
2600
2597
pub focus : NodeId ,
2601
2598
}
2602
2599
2600
+ /// The amount by which to scroll in the direction specified by one of the
2601
+ /// `Scroll` actions.
2602
+ #[ derive( Clone , Copy , Debug , PartialEq , Eq ) ]
2603
+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
2604
+ #[ cfg_attr( feature = "schemars" , derive( JsonSchema ) ) ]
2605
+ #[ cfg_attr( feature = "serde" , serde( rename_all = "camelCase" ) ) ]
2606
+ #[ cfg_attr(
2607
+ feature = "pyo3" ,
2608
+ pyclass( module = "accesskit" , rename_all = "SCREAMING_SNAKE_CASE" , eq)
2609
+ ) ]
2610
+ #[ repr( u8 ) ]
2611
+ pub enum ScrollUnit {
2612
+ /// A single item of a list, line of text (for vertical scrolling),
2613
+ /// character (for horizontal scrolling), or an approximation of
2614
+ /// one of these.
2615
+ Item ,
2616
+ /// The amount of content that fits in the viewport.
2617
+ Page ,
2618
+ }
2619
+
2603
2620
#[ derive( Clone , Debug , PartialEq ) ]
2604
2621
#[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
2605
2622
#[ cfg_attr( feature = "schemars" , derive( JsonSchema ) ) ]
@@ -2609,6 +2626,7 @@ pub enum ActionData {
2609
2626
CustomAction ( i32 ) ,
2610
2627
Value ( Box < str > ) ,
2611
2628
NumericValue ( f64 ) ,
2629
+ ScrollUnit ( ScrollUnit ) ,
2612
2630
/// Optional target rectangle for [`Action::ScrollIntoView`], in
2613
2631
/// the coordinate space of the action's target node.
2614
2632
ScrollTargetRect ( Rect ) ,
@@ -2720,23 +2738,21 @@ mod tests {
2720
2738
assert_eq ! ( Action :: n( 8 ) , Some ( Action :: HideTooltip ) ) ;
2721
2739
assert_eq ! ( Action :: n( 9 ) , Some ( Action :: ShowTooltip ) ) ;
2722
2740
assert_eq ! ( Action :: n( 10 ) , Some ( Action :: ReplaceSelectedText ) ) ;
2723
- assert_eq ! ( Action :: n( 11 ) , Some ( Action :: ScrollBackward ) ) ;
2724
- assert_eq ! ( Action :: n( 12 ) , Some ( Action :: ScrollDown ) ) ;
2725
- assert_eq ! ( Action :: n( 13 ) , Some ( Action :: ScrollForward ) ) ;
2726
- assert_eq ! ( Action :: n( 14 ) , Some ( Action :: ScrollLeft ) ) ;
2727
- assert_eq ! ( Action :: n( 15 ) , Some ( Action :: ScrollRight ) ) ;
2728
- assert_eq ! ( Action :: n( 16 ) , Some ( Action :: ScrollUp ) ) ;
2729
- assert_eq ! ( Action :: n( 17 ) , Some ( Action :: ScrollIntoView ) ) ;
2730
- assert_eq ! ( Action :: n( 18 ) , Some ( Action :: ScrollToPoint ) ) ;
2731
- assert_eq ! ( Action :: n( 19 ) , Some ( Action :: SetScrollOffset ) ) ;
2732
- assert_eq ! ( Action :: n( 20 ) , Some ( Action :: SetTextSelection ) ) ;
2741
+ assert_eq ! ( Action :: n( 11 ) , Some ( Action :: ScrollDown ) ) ;
2742
+ assert_eq ! ( Action :: n( 12 ) , Some ( Action :: ScrollLeft ) ) ;
2743
+ assert_eq ! ( Action :: n( 13 ) , Some ( Action :: ScrollRight ) ) ;
2744
+ assert_eq ! ( Action :: n( 14 ) , Some ( Action :: ScrollUp ) ) ;
2745
+ assert_eq ! ( Action :: n( 15 ) , Some ( Action :: ScrollIntoView ) ) ;
2746
+ assert_eq ! ( Action :: n( 16 ) , Some ( Action :: ScrollToPoint ) ) ;
2747
+ assert_eq ! ( Action :: n( 17 ) , Some ( Action :: SetScrollOffset ) ) ;
2748
+ assert_eq ! ( Action :: n( 18 ) , Some ( Action :: SetTextSelection ) ) ;
2733
2749
assert_eq ! (
2734
- Action :: n( 21 ) ,
2750
+ Action :: n( 19 ) ,
2735
2751
Some ( Action :: SetSequentialFocusNavigationStartingPoint )
2736
2752
) ;
2737
- assert_eq ! ( Action :: n( 22 ) , Some ( Action :: SetValue ) ) ;
2738
- assert_eq ! ( Action :: n( 23 ) , Some ( Action :: ShowContextMenu ) ) ;
2739
- assert_eq ! ( Action :: n( 24 ) , None ) ;
2753
+ assert_eq ! ( Action :: n( 20 ) , Some ( Action :: SetValue ) ) ;
2754
+ assert_eq ! ( Action :: n( 21 ) , Some ( Action :: ShowContextMenu ) ) ;
2755
+ assert_eq ! ( Action :: n( 22 ) , None ) ;
2740
2756
}
2741
2757
2742
2758
#[ test]
@@ -2808,9 +2824,7 @@ mod tests {
2808
2824
assert ! ( !node. supports_action( Action :: HideTooltip ) ) ;
2809
2825
assert ! ( !node. supports_action( Action :: ShowTooltip ) ) ;
2810
2826
assert ! ( !node. supports_action( Action :: ReplaceSelectedText ) ) ;
2811
- assert ! ( !node. supports_action( Action :: ScrollBackward ) ) ;
2812
2827
assert ! ( !node. supports_action( Action :: ScrollDown ) ) ;
2813
- assert ! ( !node. supports_action( Action :: ScrollForward ) ) ;
2814
2828
assert ! ( !node. supports_action( Action :: ScrollLeft ) ) ;
2815
2829
assert ! ( !node. supports_action( Action :: ScrollRight ) ) ;
2816
2830
assert ! ( !node. supports_action( Action :: ScrollUp ) ) ;
0 commit comments