Keyboard input, text input elements
This commit is contained in:
@@ -12,6 +12,7 @@ use ruin_runtime::{WorkerHandle, queue_future, queue_microtask, spawn_worker};
|
||||
use tracing::{debug, info};
|
||||
|
||||
use crate::interaction::PointerEvent;
|
||||
use crate::keyboard::KeyboardEvent;
|
||||
use crate::scene::{SceneSnapshot, UiSize};
|
||||
use crate::trace_targets;
|
||||
use crate::tree::CursorIcon;
|
||||
@@ -64,6 +65,18 @@ pub enum PlatformEvent {
|
||||
window_id: WindowId,
|
||||
event: PointerEvent,
|
||||
},
|
||||
Keyboard {
|
||||
window_id: WindowId,
|
||||
event: KeyboardEvent,
|
||||
},
|
||||
PrimarySelectionText {
|
||||
window_id: WindowId,
|
||||
text: String,
|
||||
},
|
||||
Wake {
|
||||
window_id: WindowId,
|
||||
token: u64,
|
||||
},
|
||||
CloseRequested {
|
||||
window_id: WindowId,
|
||||
},
|
||||
@@ -98,6 +111,9 @@ pub enum PlatformRequest {
|
||||
window_id: WindowId,
|
||||
text: String,
|
||||
},
|
||||
RequestPrimarySelectionText {
|
||||
window_id: WindowId,
|
||||
},
|
||||
SetCursorIcon {
|
||||
window_id: WindowId,
|
||||
cursor: CursorIcon,
|
||||
@@ -109,6 +125,14 @@ pub enum PlatformRequest {
|
||||
window_id: WindowId,
|
||||
event: PointerEvent,
|
||||
},
|
||||
EmitKeyboardEvent {
|
||||
window_id: WindowId,
|
||||
event: KeyboardEvent,
|
||||
},
|
||||
EmitWake {
|
||||
window_id: WindowId,
|
||||
token: u64,
|
||||
},
|
||||
Shutdown,
|
||||
}
|
||||
|
||||
@@ -223,6 +247,13 @@ impl PlatformProxy {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn request_primary_selection_text(
|
||||
&self,
|
||||
window_id: WindowId,
|
||||
) -> Result<(), PlatformClosed> {
|
||||
self.send(PlatformRequest::RequestPrimarySelectionText { window_id })
|
||||
}
|
||||
|
||||
pub fn set_cursor_icon(
|
||||
&self,
|
||||
window_id: WindowId,
|
||||
@@ -243,6 +274,18 @@ impl PlatformProxy {
|
||||
self.send(PlatformRequest::EmitPointerEvent { window_id, event })
|
||||
}
|
||||
|
||||
pub fn emit_keyboard_event(
|
||||
&self,
|
||||
window_id: WindowId,
|
||||
event: KeyboardEvent,
|
||||
) -> Result<(), PlatformClosed> {
|
||||
self.send(PlatformRequest::EmitKeyboardEvent { window_id, event })
|
||||
}
|
||||
|
||||
pub fn emit_wake(&self, window_id: WindowId, token: u64) -> Result<(), PlatformClosed> {
|
||||
self.send(PlatformRequest::EmitWake { window_id, token })
|
||||
}
|
||||
|
||||
pub fn shutdown(&self) -> Result<(), PlatformClosed> {
|
||||
self.send(PlatformRequest::Shutdown)
|
||||
}
|
||||
@@ -286,6 +329,7 @@ pub fn start_headless() -> PlatformRuntime {
|
||||
handle_replace_scene(&state, window_id, scene);
|
||||
}
|
||||
PlatformRequest::SetPrimarySelectionText { .. } => {}
|
||||
PlatformRequest::RequestPrimarySelectionText { .. } => {}
|
||||
PlatformRequest::SetCursorIcon { .. } => {}
|
||||
PlatformRequest::EmitCloseRequested { window_id } => {
|
||||
let sender = state.borrow().events.clone();
|
||||
@@ -294,6 +338,14 @@ pub fn start_headless() -> PlatformRuntime {
|
||||
PlatformRequest::EmitPointerEvent { window_id, event } => {
|
||||
handle_emit_pointer_event(&state, window_id, event);
|
||||
}
|
||||
PlatformRequest::EmitKeyboardEvent { window_id, event } => {
|
||||
let sender = state.borrow().events.clone();
|
||||
let _ = sender.send(PlatformEvent::Keyboard { window_id, event });
|
||||
}
|
||||
PlatformRequest::EmitWake { window_id, token } => {
|
||||
let sender = state.borrow().events.clone();
|
||||
let _ = sender.send(PlatformEvent::Wake { window_id, token });
|
||||
}
|
||||
PlatformRequest::Shutdown => {
|
||||
debug!(
|
||||
target: trace_targets::PLATFORM,
|
||||
|
||||
Reference in New Issue
Block a user