From 63cd0fd8eb1eebae8de7d5141c846fc4ea55d702 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 30 Oct 2019 03:31:07 +0100 Subject: Draft `TextInput` widget structure Also started a `todos` example to showcase it! --- winit/src/conversion.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'winit/src') diff --git a/winit/src/conversion.rs b/winit/src/conversion.rs index bb0d252e..e73fa008 100644 --- a/winit/src/conversion.rs +++ b/winit/src/conversion.rs @@ -9,6 +9,7 @@ pub fn mouse_cursor(mouse_cursor: MouseCursor) -> winit::window::CursorIcon { MouseCursor::Working => winit::window::CursorIcon::Progress, MouseCursor::Grab => winit::window::CursorIcon::Grab, MouseCursor::Grabbing => winit::window::CursorIcon::Grabbing, + MouseCursor::Text => winit::window::CursorIcon::Text, } } -- cgit From fedcab6f4f5ffd3a6dfffe7dd41c58df2e314099 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 30 Oct 2019 05:00:12 +0100 Subject: Handle some `TextInput` events --- winit/src/application.rs | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'winit/src') diff --git a/winit/src/application.rs b/winit/src/application.rs index c8748199..b90b5eef 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -1,6 +1,8 @@ use crate::{ - column, conversion, input::mouse, renderer::Windowed, Cache, Column, - Element, Event, Length, MouseCursor, UserInterface, + column, conversion, + input::{keyboard, mouse}, + renderer::Windowed, + Cache, Column, Element, Event, Length, MouseCursor, UserInterface, }; pub trait Application { @@ -167,6 +169,25 @@ pub trait Application { )); } }, + WindowEvent::ReceivedCharacter(c) => { + events.push(Event::Keyboard( + keyboard::Event::CharacterReceived(c), + )); + } + WindowEvent::KeyboardInput { + input: + winit::event::KeyboardInput { + virtual_keycode: Some(virtual_keycode), + state, + .. + }, + .. + } => { + events.push(Event::Keyboard(keyboard::Event::Input { + key_code: conversion::key_code(virtual_keycode), + state: conversion::button_state(state), + })); + } WindowEvent::CloseRequested => { *control_flow = ControlFlow::Exit; } -- cgit