Skip to main content

dear_imgui_rs/widget/misc/
item_key.rs

1use crate::Ui;
2use crate::sys;
3
4// ============================================================================
5// Item key ownership
6// ============================================================================
7
8impl Ui {
9    /// Set the key owner for the last item, without flags.
10    ///
11    /// Returns `true` when ownership was requested for the item.
12    #[doc(alias = "SetItemKeyOwner")]
13    pub fn set_item_key_owner(&self, key: crate::input::Key) -> bool {
14        let k: sys::ImGuiKey = key as sys::ImGuiKey;
15        unsafe { sys::igSetItemKeyOwner_Nil(k) }
16    }
17
18    /// Set the key owner for the last item with input flags.
19    ///
20    /// Returns `true` when ownership was requested for the item.
21    #[doc(alias = "SetItemKeyOwner")]
22    pub fn set_item_key_owner_with_flags(
23        &self,
24        key: crate::input::Key,
25        flags: crate::input::ItemKeyOwnerFlags,
26    ) -> bool {
27        let k: sys::ImGuiKey = key as sys::ImGuiKey;
28        unsafe { sys::igSetItemKeyOwner_InputFlags(k, flags.raw()) }
29    }
30}