diff --git a/imgui/src/popups.rs b/imgui/src/popups.rs index 2171537..3cc3d0e 100644 --- a/imgui/src/popups.rs +++ b/imgui/src/popups.rs @@ -249,7 +249,10 @@ impl Ui { } /// Open and begin popup when clicked with the right mouse button on last item. - /// If you want to use that on a non-interactive item such as text() use [`Self::begin_popup_context_item_id`]. + /// + /// This does not take a label, which means that multiple calls **in a row** will use the same label, which + /// is based on the last node which had a label. Text and other non-interactive elements generally don't have + /// ids, so you'll need to use [begin_popup_context_with_label] for them. #[doc(alias = "BeginPopupContextItem")] pub fn begin_popup_context_item(&self) -> Option> { let render = unsafe { @@ -266,10 +269,12 @@ impl Ui { } } - /// Open and begin popup when clicked with the right mouse button on the given item. - /// If you want to use the last item and it has an id you, you can use [`Self::begin_popup_context_item`]. + /// Open and begin popup when clicked with the right mouse button on the given item with a dedicated label. + /// + /// If you want to use the label of the previous popup (outside of `Text` and other non-interactive cases, that + /// is the more normal case), use [begin_popup_context_item]. #[doc(alias = "BeginPopupContextItem")] - pub fn begin_popup_context_item_id>( + pub fn begin_popup_context_with_label>( &self, str_id: Label, ) -> Option> { @@ -288,8 +293,32 @@ impl Ui { } /// Open and begin popup when clicked on current window. + /// + /// This does not take a label, which means that multiple calls will use the same provided label. + /// If you want an explicit label, such as having two different kinds of windows popups in your program, + /// use [begin_popup_context_window_with_label]. #[doc(alias = "BeginPopupContextWindow")] - pub fn begin_popup_context_window>( + pub fn begin_popup_context_window(&self) -> Option> { + let render = unsafe { + sys::igBeginPopupContextWindow( + std::ptr::null(), + imgui_sys::ImGuiPopupFlags_MouseButtonRight as i32, + ) + }; + + if render { + Some(PopupToken::new(self)) + } else { + None + } + } + + /// Open and begin popup when clicked on current window. + /// + /// This takes a label explicitly. This is useful when multiple code + /// locations may want to manipulate/open the same popup, given an explicit id. + #[doc(alias = "BeginPopupContextWindow")] + pub fn begin_popup_context_window_with_label>( &self, str_id: Label, ) -> Option> { @@ -308,8 +337,32 @@ impl Ui { } /// Open and begin popup when right clicked in void (where there are no windows). + /// + /// This does not take a label, which means that multiple calls will use the same provided label. + /// If you want an explicit label, such as having two different kinds of void popups in your program, + /// use [begin_popup_context_void_with_label]. + #[doc(alias = "BeginPopupContextWindow")] + pub fn begin_popup_context_void(&self) -> Option> { + let render = unsafe { + sys::igBeginPopupContextVoid( + std::ptr::null(), + imgui_sys::ImGuiPopupFlags_MouseButtonRight as i32, + ) + }; + + if render { + Some(PopupToken::new(self)) + } else { + None + } + } + + /// Open and begin popup when right clicked in void (where there are no windows). + /// + /// This takes a label explicitly. This is useful when multiple code + /// locations may want to manipulate/open the same popup, given an explicit id. #[doc(alias = "BeginPopupContextVoid")] - pub fn begin_popup_context_void>( + pub fn begin_popup_context_void_with_label>( &self, str_id: Label, ) -> Option> {