Issue
I am trying to use OnGenericMotionListener with GLSurfaceView but it never fires when i turn the dial of my watch.
@OptIn(ExperimentalComposeUiApi::class)
@Composable
fun StarMap() {
val focusRester = remember{FocusRequester()}
AndroidViewBinding(StarviewFragmentBinding::inflate, Modifier.onRotaryScrollEvent {
Log.d("Rotary", it.verticalScrollPixels.toString())
true
}.onPreRotaryScrollEvent {
Log.d("Rotary", it.verticalScrollPixels.toString())
true
}.focusRequester(focusRester).focusable()) {
val myFragment = fragmentContainerView[0]
myFragment.requestFocus()
android.util.Log.d("Map", myFragment.javaClass.name)
// ...
}
}
Has anyone used the rotary input with GLSurfaceView on wear os app?
Solution
Use focusRester.requestFocus()
instead of myFragment.requestFocus()
If you want to use Modifier.onRotaryScrollEvent you need to call requestFocus() on the FocusRequester you pass to your composable.
Answered By - Yuri Schimke
Answer Checked By - Timothy Miller (JavaFixing Admin)