1 /* 2 * Copyright 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package androidx.compose.ui.input.rotary 18 19 import androidx.compose.ui.Modifier 20 import androidx.compose.ui.node.DelegatableNode 21 22 /** 23 * Implement this interface to create a [Modifier.Node] that can intercept rotary scroll events. 24 * 25 * The event is routed to the focused item. Before reaching the focused item, 26 * [onPreRotaryScrollEvent]() is called for parents of the focused item. If the parents don't 27 * consume the event, [onPreRotaryScrollEvent]() is called for the focused item. If the event is 28 * still not consumed, [onRotaryScrollEvent]() is called on the focused item's parents. 29 */ 30 interface RotaryInputModifierNode : DelegatableNode { 31 /** 32 * This function is called when a [RotaryScrollEvent] is received by this node during the upward 33 * pass. While implementing this callback, return true to stop propagation of this event. If you 34 * return false, the key event will be sent to this [RotaryInputModifierNode]'s parent. 35 */ onRotaryScrollEventnull36 fun onRotaryScrollEvent(event: RotaryScrollEvent): Boolean 37 38 /** 39 * This function is called when a [RotaryScrollEvent] is received by this node during the 40 * downward pass. It gives ancestors of a focused component the chance to intercept an event. 41 * Return true to stop propagation of this event. If you return false, the event will be sent to 42 * this [RotaryInputModifierNode]'s child. If none of the children consume the event, it will be 43 * sent back up to the root using the [onRotaryScrollEvent] function. 44 */ 45 fun onPreRotaryScrollEvent(event: RotaryScrollEvent): Boolean 46 } 47