logo
pub trait Activity<R>: Context {
    type Error: Sized + Debug;

Show 27 methods fn resized(
        &mut self,
        runner: &mut R,
        context: &mut Self::Context,
        width: u32,
        height: u32
    ); fn render(
        &mut self,
        runner: &mut R,
        context: &mut Self::Context,
        t: Time
    ) -> bool; fn suspend(&mut self, runner: &mut R, context: &mut Self::Context) { ... } fn resume(&mut self, runner: &mut R, context: &mut Self::Context) { ... } fn moved(
        &mut self,
        runner: &mut R,
        context: &mut Self::Context,
        x: i32,
        y: i32
    ) { ... } fn close(
        &mut self,
        runner: &mut R,
        context: &mut Self::Context
    ) -> ControlFlow { ... } fn destroyed(&mut self, runner: &mut R, context: &mut Self::Context) { ... } fn dropped_file(
        &mut self,
        runner: &mut R,
        context: &mut Self::Context,
        path: &PathBuf
    ) { ... } fn hovered_file(
        &mut self,
        runner: &mut R,
        context: &mut Self::Context,
        path: &PathBuf
    ) { ... } fn hovered_file_cancelled(
        &mut self,
        runner: &mut R,
        context: &mut Self::Context
    ) { ... } fn received_character(
        &mut self,
        runner: &mut R,
        context: &mut Self::Context,
        character: char
    ) { ... } fn focused(
        &mut self,
        runner: &mut R,
        context: &mut Self::Context,
        is_focused: bool
    ) { ... } fn keyboard_input(
        &mut self,
        runner: &mut R,
        context: &mut Self::Context,
        device_id: &DeviceId,
        input: &KeyboardInput,
        is_synthetic: bool
    ) -> ControlFlow { ... } fn modifiers_changed(
        &mut self,
        runner: &mut R,
        context: &mut Self::Context,
        state: &ModifiersState
    ) { ... } fn cursor_moved(
        &mut self,
        runner: &mut R,
        context: &mut Self::Context,
        device_id: &DeviceId,
        position: &PhysicalPosition<f64>
    ) { ... } fn cursor_entered(
        &mut self,
        runner: &mut R,
        context: &mut Self::Context,
        device_id: &DeviceId
    ) { ... } fn cursor_left(
        &mut self,
        runner: &mut R,
        context: &mut Self::Context,
        device_id: &DeviceId
    ) { ... } fn mouse_wheel(
        &mut self,
        runner: &mut R,
        context: &mut Self::Context,
        device_id: &DeviceId,
        delta: &MouseScrollDelta,
        phase: &TouchPhase
    ) { ... } fn mouse_input(
        &mut self,
        runner: &mut R,
        context: &mut Self::Context,
        device_id: &DeviceId,
        state: &ElementState,
        button: &MouseButton
    ) { ... } fn touchpad_pressure(
        &mut self,
        runner: &mut R,
        context: &mut Self::Context,
        device_id: &DeviceId,
        pressure: f32,
        stage: i64
    ) { ... } fn axis_motion(
        &mut self,
        runner: &mut R,
        context: &mut Self::Context,
        device_id: &DeviceId,
        axis: &u32,
        value: f64
    ) { ... } fn touch(
        &mut self,
        runner: &mut R,
        context: &mut Self::Context,
        touch: &Touch
    ) { ... } fn scale_factor_changed(
        &mut self,
        runner: &mut R,
        context: &mut Self::Context,
        scale_factor: f64,
        new_inner_size: &&mut PhysicalSize<u32>
    ) { ... } fn theme_changed(
        &mut self,
        runner: &mut R,
        context: &mut Self::Context,
        theme: &Theme
    ) { ... } fn main_events_cleared(
        &mut self,
        runner: &mut R,
        context: &mut Self::Context
    ) -> bool { ... } fn before_event(
        &mut self,
        runner: &mut R,
        context: &mut Self::Context,
        event: &WindowEvent<'_>
    ) { ... } fn after_event(
        &mut self,
        runner: &mut R,
        context: &mut Self::Context,
        event: &WindowEvent<'_>
    ) { ... }
}
Expand description

Defines application behavior

Simple application is basically just a single fn that takes the current time and display something.

Required Associated Types

Initialization error that might occur.

Required Methods

Resize the application when the framebuffer gets resized.

The runner is passed so that specific resizing is possible.

Render the application at a given time.

The runner is passed so that specific rendering is possible. return agressive state. true for applications which FPS aggressive, like a games or animation/media oriented applications. also you can change the behaviour for your needs.

Provided Methods

Notify the application has been suspended.

Notify the application has been resumed.

The position of the window has changed. Contains the window’s new position.

The window has been requested to close.

By default application will exit

The window has been destroyed.

A file has been dropped into the window.

When the user drops multiple files at once, this event will be emitted for each file separately.

A file is being hovered over the window.

When the user hovers multiple files at once, this event will be emitted for each file separately.

A file was hovered, but has exited the window.

There will be a single HoveredFileCancelled event triggered even if multiple files were hovered.

The window received a unicode character.

The window gained or lost focus.

The parameter is true if the window has gained focus, and false if it has lost focus.

An event from the keyboard has been received.

If true, the event was generated synthetically by winit in one of the following circumstances:

Synthetic key press events are generated for all keys pressed when a window gains focus. Likewise, synthetic key release events are generated for all keys pressed when a window goes out of focus. Currently, this is only functional on X11 and Windows

Otherwise, this value is always false.

The keyboard modifiers have changed.

Platform-specific behavior:

  • Web: This API is currently unimplemented on the web. This isn’t by design - it’s an issue, and it should get fixed - but it’s the current state of the API.

The cursor has moved on the window.

(x,y) coords in pixels relative to the top-left corner of the window. Because the range of this data is limited by the display area and it may have been transformed by the OS to implement effects such as cursor acceleration, it should not be used to implement non-cursor-like interactions such as 3D camera control.

The cursor has entered the window.

The cursor has left the window.

A mouse wheel movement or touchpad scroll occurred.

An mouse button press has been received.

Touchpad pressure event.

At the moment, only supported on Apple forcetouch-capable macbooks. The parameters are: pressure level (value between 0 and 1 representing how hard the touchpad is being pressed) and stage (integer representing the click level).

Motion on some analog axis. May report data redundant to other, more specific events.

Touch event has been received

The window’s scale factor has changed.

The following user actions can cause DPI changes:

Changing the display’s resolution. Changing the display’s scale factor (e.g. in Control Panel on Windows). Moving the window to a display with a different scale factor.

After this event callback has been processed, the window will be resized to whatever value is pointed to by the new_inner_size reference. By default, this will contain the size suggested by the OS, but it can be changed to any value.

The system window theme has changed.

Applications might wish to react to this to change the theme of the content of the window when the system changes the window theme.

At the moment this is only supported on Windows.

Analogue of winit::MainEventsCleared

Used to route winit :: WindowEvent to external handlers (third party UI handlers, etc.). Called before internal matching

Used to route winit :: WindowEvent to external handlers (third party UI handlers, etc.). Called after internal matching

Implementors