Add a global key callback
This commit is contained in:
parent
c6ecbfb129
commit
d79db4acb3
2 changed files with 13 additions and 5 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "mosaic-tile"
|
name = "mosaic-tile"
|
||||||
version = "0.2.1"
|
version = "0.2.2"
|
||||||
authors = ["Brooks J Rady <b.j.rady@gmail.com>"]
|
authors = ["Brooks J Rady <b.j.rady@gmail.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
description = "A small client-side library for writing mosaic plugins (tiles)"
|
description = "A small client-side library for writing mosaic plugins (tiles)"
|
||||||
|
|
|
||||||
16
src/lib.rs
16
src/lib.rs
|
|
@ -1,11 +1,12 @@
|
||||||
mod shim;
|
mod shim;
|
||||||
|
|
||||||
pub use shim::*;
|
pub use shim::*;
|
||||||
|
#[allow(unused_variables)]
|
||||||
pub trait MosaicTile {
|
pub trait MosaicTile {
|
||||||
fn init(&mut self);
|
fn init(&mut self) {}
|
||||||
fn draw(&mut self, rows: usize, cols: usize);
|
fn draw(&mut self, rows: usize, cols: usize) {}
|
||||||
fn handle_key(&mut self, key: Key);
|
fn handle_key(&mut self, key: Key) {}
|
||||||
|
fn handle_global_key(&mut self, key: Key) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
|
|
@ -37,5 +38,12 @@ macro_rules! register_tile {
|
||||||
state.borrow_mut().handle_key(get_key());
|
state.borrow_mut().handle_key(get_key());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub fn handle_global_key() {
|
||||||
|
STATE.with(|state| {
|
||||||
|
state.borrow_mut().handle_global_key(get_key());
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue