diff options
| author | Arne Dußin | 2020-12-21 01:22:15 +0100 |
|---|---|---|
| committer | Arne Dußin | 2020-12-21 21:15:55 +0100 |
| commit | d7e9c3cc46d616c2fcd1a6e9f73adbb79c6570b4 (patch) | |
| tree | e5633f4d3b18472922c943d759e9f58722ba4405 /src/button.rs | |
| parent | 48f321a80970ebeb8374072b1d2e0a4d297aa348 (diff) | |
| download | graf_karto-d7e9c3cc46d616c2fcd1a6e9f73adbb79c6570b4.tar.gz graf_karto-d7e9c3cc46d616c2fcd1a6e9f73adbb79c6570b4.zip | |
Add previously missing docs where appropriate
Diffstat (limited to 'src/button.rs')
| -rw-r--r-- | src/button.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/button.rs b/src/button.rs index 89ce9a5..846377e 100644 --- a/src/button.rs +++ b/src/button.rs @@ -11,10 +11,13 @@ use std::mem; /// user has free reign over what key they use for what purpose. #[derive(Serialize, Deserialize, Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum Button { + /// Button on the mouse with internal mouse button representation of raylib. Mouse(MouseButton), + /// Keyboard button with internal keyboard key representation of raylib. Keyboard(KeyboardKey), } +#[allow(missing_docs)] #[repr(u32)] #[derive(Serialize, Deserialize, Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum MouseButton { @@ -23,6 +26,7 @@ pub enum MouseButton { Middle = 2, } +#[allow(missing_docs)] #[repr(u32)] #[derive(Serialize, Deserialize, Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum KeyboardKey { @@ -134,6 +138,9 @@ pub enum KeyboardKey { } impl Button { + /// Check if this button is pressed. If `mouse_blocked` is true, mouse buttons are ignored which + /// is useful when an element has captured the mouse, but other elements are still queried in the + /// background. pub fn is_pressed(self, rl: &RaylibHandle, mouse_blocked: bool) -> bool { match self { Self::Mouse(button) => !mouse_blocked && rl.is_mouse_button_pressed(button.into()), |
