From 3bc00f5f3f030acc8dbbf8018f6c2a99561ca709 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Sun, 10 Feb 2019 20:37:02 +0100 Subject: Update organisation and document --- src/widgets/menu.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/widgets/menu.rs') diff --git a/src/widgets/menu.rs b/src/widgets/menu.rs index fe899e3..f90e62b 100644 --- a/src/widgets/menu.rs +++ b/src/widgets/menu.rs @@ -1,3 +1,9 @@ +//! A selection menu. +//! +//! The configuration for a menu is encapsulated in a `Data` struct, which +//! contains some number of `Item` structs which describe the individual items +//! to be chosen between. + use std::ffi::c_void; use crate::bindings; @@ -46,10 +52,15 @@ impl Menu { } } + /// Called automatically; should only be needed if something else overwrote + /// the widget. pub fn redraw(&self) { unsafe { bindings::menu_redraw(self.ptr); } } + /// Process the given key in the context of the menu. + /// + /// The key should be a return value from `Keyboard::get_key()`. pub fn handle_key(&mut self, key: i32) -> KeyResult { match unsafe { bindings::menu_handlekey(self.ptr, key) } { bindings::Menukey_MENUKEY_HANDLED => KeyResult::Handled, -- cgit v1.2.3-70-g09d2