File tree Expand file tree Collapse file tree
plugins/continuous-toolbox/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -192,6 +192,23 @@ export class ContinuousFlyout extends Blockly.VerticalFlyout {
192192 this . scrollTo ( position ) ;
193193 }
194194
195+ /**
196+ * Returns the header item in the flyout corresponding to the given
197+ * toolbox category, if any.
198+ */
199+ headerForCategory (
200+ category : Blockly . ISelectableToolboxItem ,
201+ ) : Blockly . IFocusableNode | undefined {
202+ return this . getContents ( )
203+ . find ( ( item ) => {
204+ return (
205+ this . toolboxItemIsLabel ( item ) &&
206+ item . getElement ( ) . getButtonText ( ) === category . getName ( )
207+ ) ;
208+ } )
209+ ?. getElement ( ) ;
210+ }
211+
195212 /**
196213 * Step the scrolling animation by scrolling a fraction of the way to
197214 * a scroll target, and request the next frame if necessary.
Original file line number Diff line number Diff line change 1010
1111import * as Blockly from 'blockly/core' ;
1212import { ContinuousFlyout } from './ContinuousFlyout' ;
13+ import { ContinuousToolboxNavigator } from './ContinuousToolboxNavigator' ;
1314
1415/**
1516 * Class for continuous toolbox.
@@ -21,6 +22,12 @@ export class ContinuousToolbox extends Blockly.Toolbox {
2122 */
2223 private refreshDebouncer ?: ReturnType < typeof setTimeout > ;
2324
25+ /**
26+ * Navigator object responsible for handling keyboard navigation within this
27+ * toolbox.
28+ */
29+ private continuousToolboxNavigator = new ContinuousToolboxNavigator ( this ) ;
30+
2431 /**
2532 * Initializes the continuous toolbox.
2633 */
@@ -192,4 +199,12 @@ export class ContinuousToolbox extends Blockly.Toolbox {
192199 }
193200 return super . getClientRect ( ) ;
194201 }
202+
203+ /**
204+ * Returns the Navigator object responsible for handling keyboard navigation
205+ * inside this toolbox.
206+ */
207+ override getNavigator ( ) : Blockly . ToolboxNavigator {
208+ return this . continuousToolboxNavigator ;
209+ }
195210}
Original file line number Diff line number Diff line change 1+ /**
2+ * @license
3+ * Copyright 2026 Raspberry Pi Foundation
4+ * SPDX-License-Identifier: Apache-2.0
5+ */
6+
7+ import * as Blockly from 'blockly/core' ;
8+ import { ContinuousToolbox } from './ContinuousToolbox' ;
9+ import { ContinuousCategory } from './ContinuousCategory' ;
10+
11+ /**
12+ * A Navigator that handles keyboard navigation within a continuous toolbox.
13+ */
14+ export class ContinuousToolboxNavigator extends Blockly . ToolboxNavigator {
15+ constructor ( protected toolbox : ContinuousToolbox ) {
16+ super ( toolbox ) ;
17+ }
18+
19+ /**
20+ * Returns the next node when navigating "in", in this case the first flyout
21+ * item in the toolbox's currently selected category.
22+ */
23+ override getInNode (
24+ node = Blockly . getFocusManager ( ) . getFocusedNode ( ) ,
25+ ) : Blockly . IFocusableNode | null {
26+ if ( ! ( node instanceof ContinuousCategory ) ) return null ;
27+ return this . toolbox . getFlyout ( ) . headerForCategory ( node ) ?? null ;
28+ }
29+ }
You can’t perform that action at this time.
0 commit comments