1 /* 2 * Copyright 2025 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.indirect 18 19 import androidx.compose.ui.ExperimentalComposeUiApi 20 import androidx.compose.ui.Modifier 21 import androidx.compose.ui.node.DelegatableNode 22 23 /** 24 * Implement this interface to create a [Modifier.Node] that can intercept indirect touch input 25 * events. 26 * 27 * The event is routed to the focused item. Before reaching the focused item, 28 * [onPreIndirectTouchEvent] is called for parents of the focused item. If the parents don't consume 29 * the event, [onPreIndirectTouchEvent] is called for the focused item. If the event is still not 30 * consumed, [onIndirectTouchEvent] is called on the focused item's parents. 31 */ 32 @ExperimentalComposeUiApi 33 interface IndirectTouchInputModifierNode : DelegatableNode { 34 35 /** 36 * This function is called when an [IndirectTouchEvent] is received by this node during the 37 * upward pass. While implementing this callback, return true to stop propagation of this event. 38 * If you return false, the generic motion event will be sent to this 39 * [IndirectTouchInputModifierNode]'s parent. 40 */ onIndirectTouchEventnull41 fun onIndirectTouchEvent(event: IndirectTouchEvent): Boolean 42 43 /** 44 * This function is called when an [IndirectTouchEvent] is received by this node during the 45 * downward pass. It gives ancestors of a focused component the chance to intercept an event. 46 * Return true to stop propagation of this event. If you return false, the event will be sent to 47 * this [IndirectTouchInputModifierNode]'s child. If none of the children consume the event, it 48 * will be sent back up to the root using the [onIndirectTouchEvent] function. 49 */ 50 fun onPreIndirectTouchEvent(event: IndirectTouchEvent): Boolean 51 } 52