Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to support touchscreen? #1555

Open
Richyeoh opened this issue Dec 7, 2021 · 8 comments
Open

How to support touchscreen? #1555

Richyeoh opened this issue Dec 7, 2021 · 8 comments
Assignees
Labels
desktop enhancement New feature or request

Comments

@Richyeoh
Copy link

Richyeoh commented Dec 7, 2021

I have a window pad,I running app on that,App is very simple just a LazyColumn,It can use mouse wheel scroll,but not use touchscreen scroll.

@Richyeoh
Copy link
Author

Richyeoh commented Dec 7, 2021

I see Modifier extensions function has a mouseScroll and mouseTouch,How to use it ? Thx~

@Richyeoh
Copy link
Author

Richyeoh commented Dec 7, 2021

Hi @akurasov, Do you know how to solve this problem? I saw that you mentioned relevant problems and tried, but I still can't solve the problem of dragging and scrolling on the touch screen.

@Richyeoh
Copy link
Author

Richyeoh commented Dec 7, 2021

val scrollState = rememberLazyListState()
val data = (0 until 1000).map { "Item $it" }
LazyColumn(
    modifier = Modifier.draggable(rememberDraggableState { delta ->
        println("delta=$delta")
        runBlocking {
            scrollState.scrollBy(-delta)
        }
    }, orientation = Orientation.Vertical),
    state = scrollState
) {
    items(data) { i ->
        Text(
            i,
            Modifier
                .padding(14.dp)
                .fillMaxWidth()
        )
    }
}

See above code:
Maybe, I has solve the problem.

@akurasov
Copy link
Contributor

akurasov commented Dec 8, 2021

Yes, if you want to handle dragging gesture, you should use this API.

There is no explicit touch screen support, Compose relies on OS level conversion of touch Screen events to mouse events.

@akurasov akurasov self-assigned this Dec 8, 2021
@akurasov akurasov added desktop question Not a bug, but question or comment wait for reply Further information is requested labels Dec 8, 2021
@hasali19
Copy link

hasali19 commented Feb 7, 2022

Is there a plan to implement proper touch screen support? I actually attempted to pass through touch events while trying out compose, using the ComposeScene, but found that certain components such as TextField are hard coded to only work properly for mouse input on desktop.

@akurasov akurasov added enhancement New feature or request Saved and removed wait for reply Further information is requested question Not a bug, but question or comment labels Feb 11, 2022
@akurasov akurasov reopened this Feb 11, 2022
@akurasov
Copy link
Contributor

There are no immediate plans for it. Could you please describe some scenarios, where current support is not enough?

@hasali19
Copy link

There's no fling behaviour when scrolling with the above method, and no way to differentiate between mouse and touch gestures.

@ianbrandt
Copy link

ianbrandt commented Apr 17, 2024

There are no immediate plans for it. Could you please describe some scenarios, where current support is not enough?

My use case is a GUI client that includes 2D and 3D mapping functionality. It can be run on any Windows or Linux multitouch-enabled device. Examples include laptops and desktops with monitors having multitouch support, Microsoft Surface and Linux tablet devices, and similar. For 2D maps (think Google Maps) it supports simultaneous pinch-to-zoom, drag-to-pan, and twist-to-rotate two-finger gestures. For 3D maps (think Google Earth) it's the same, with the addition that switching to three-fingered gestures changes drag-to-pan to drag-to-pan-horizontally-and-tilt-vertically. The client can sometimes be used in high-criticality (i.e. potential loss of life) situations, so precise, performant touch and gesture control is vital.

Currently we use OpenJFX for this, in particular its TouchEvent and GestureEvent multitouch support. See also "Handling JavaFX Events: Working with Events from Touch-Enabled Devices" and "Handling JavaFX Events: Working with Touch Events".

I'd like to consider porting to Compose Multiplatform in the future to support Windows and Linux desktop, Android, and WASM targets all from a single client, but multitouch support would be required for each.

I could also see gaming and 3D modelling applications being two other use cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
desktop enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants