Feat: yeet, synthetic somewhat wired up

This commit is contained in:
Jonathan Kelley committed 2021-03-04 18:40:05 -05:00
1 parent 3087813570
commit d9598066c2
7 files changed
+79 -47

No files matched your search

+15 -15
View File
@@ -93,7 +93,7 @@ pub mod on {
};
}
struct GetModifierKey(Box<dyn Fn(usize) -> bool>);
pub struct GetModifierKey(pub Box<dyn Fn(usize) -> bool>);
impl std::fmt::Debug for GetModifierKey {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
// just skip for now
@@ -159,7 +159,7 @@ pub mod on {
}
#[derive(Debug)]
pub struct MouseEvent(Box<RawMouseEvent>);
pub struct MouseEvent(pub Box<RawMouseEvent>);
impl Deref for MouseEvent {
type Target = RawMouseEvent;
fn deref(&self) -> &Self::Target {
@@ -168,19 +168,19 @@ pub mod on {
}
#[derive(Debug)]
pub struct RawMouseEvent {
alt_key: bool,
button: usize,
buttons: usize,
client_x: i32,
client_y: i32,
ctrl_key: bool,
meta_key: bool,
page_x: i32,
page_y: i32,
screen_x: i32,
screen_y: i32,
shift_key: bool,
get_modifier_state: GetModifierKey,
pub alt_key: bool,
pub button: i32,
pub buttons: i32,
pub client_x: i32,
pub client_y: i32,
pub ctrl_key: bool,
pub meta_key: bool,
pub page_x: i32,
pub page_y: i32,
pub screen_x: i32,
pub screen_y: i32,
pub shift_key: bool,
pub get_modifier_state: GetModifierKey,
// relatedTarget: DOMEventTarget,
}
event_builder! {
-1
View File
@@ -178,7 +178,6 @@ mod use_reducer_def {
use super::*;
use crate::prelude::*;
use bumpalo::Bump;
enum Actions {
Incr,
Decr,
+7 -7
View File
@@ -339,18 +339,18 @@ where
/// })
/// .finish();
/// ```
#[inline]
pub fn on(mut self, event: &'static str, callback: impl Fn(VirtualEvent) + 'a) -> Self {
// todo:
// increment listner id from nodectx ref
// add listener attrs here instead of later?
self.listeners.push(Listener {
let listener = Listener {
event,
callback: self.ctx.bump.alloc(callback),
id: *self.ctx.idx.borrow(),
scope: self.ctx.scope,
});
};
self.add_listener(listener)
}
pub fn add_listener(mut self, listener: Listener<'a>) -> Self {
self.listeners.push(listener);
// bump the context id forward
*self.ctx.idx.borrow_mut() += 1;