Skip to content

Touch gesture support #279

@emilk

Description

@emilk

It would be great if egui could support pinch-to-zoom, multi-finger swipes and other touch gestures. For a start, the most important place to support it is the web (i.e. in egui_web).

(NOTE: full multi-touch support, e.g. dragging two sliders at once, is a separate issue).

I suggest we start by adding touch events to egui::Event. Let's do something similar to winit:

enum Event {Touch(TouchEvent),
}

pub struct TouchId(pub u64);

struct TouchEvent {
    id: TouchId,
    pos: Pos2,
    phase: TouchPhase,
}

pub enum TouchPhase {
    Started,
    Moved,
    Ended,
    Cancelled,
}

egui::InputState can then keep track of the touches in a HashMap<TouchId, Pos2> and detect gestures. For instance, if there is exactly two touches then it could measure zoom, translation and rotation to support manipulating 2D surfaces. An egui application would then just do something like self.zoom *= ui.input().zoom(); to update its zoom-state each frame.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or requestwebRelated to running Egui on the web

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions