mirror of
https://github.com/eliasstepanik/imgui-rs.git
synced 2026-01-11 05:28:35 +00:00
Add functions begin_popup_context_*.
This commit is contained in:
parent
4c80d0d5f3
commit
1d0858c5a3
@ -247,6 +247,85 @@ impl Ui {
|
||||
pub fn close_current_popup(&self) {
|
||||
unsafe { sys::igCloseCurrentPopup() };
|
||||
}
|
||||
|
||||
/// Open+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`].
|
||||
#[doc(alias = "BeginPopupContextItem")]
|
||||
pub fn begin_popup_context_item(&self) -> Option<PopupToken<'_>> {
|
||||
let render = unsafe {
|
||||
sys::igBeginPopupContextItem(
|
||||
std::ptr::null(),
|
||||
imgui_sys::ImGuiPopupFlags_MouseButtonRight as i32,
|
||||
)
|
||||
};
|
||||
|
||||
if render {
|
||||
Some(PopupToken::new(self))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
/// Open+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`].
|
||||
#[doc(alias = "BeginPopupContextItem")]
|
||||
pub fn begin_popup_context_item_id<Label: AsRef<str>>(
|
||||
&self,
|
||||
str_id: Label,
|
||||
) -> Option<PopupToken<'_>> {
|
||||
let render = unsafe {
|
||||
sys::igBeginPopupContextItem(
|
||||
self.scratch_txt(str_id),
|
||||
imgui_sys::ImGuiPopupFlags_MouseButtonRight as i32,
|
||||
)
|
||||
};
|
||||
|
||||
if render {
|
||||
Some(PopupToken::new(self))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
/// Open+begin popup when clicked on current window.
|
||||
#[doc(alias = "BeginPopupContextWindow")]
|
||||
pub fn begin_popup_context_window<Label: AsRef<str>>(
|
||||
&self,
|
||||
str_id: Label,
|
||||
) -> Option<PopupToken<'_>> {
|
||||
let render = unsafe {
|
||||
sys::igBeginPopupContextWindow(
|
||||
self.scratch_txt(str_id),
|
||||
imgui_sys::ImGuiPopupFlags_MouseButtonRight as i32,
|
||||
)
|
||||
};
|
||||
|
||||
if render {
|
||||
Some(PopupToken::new(self))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
/// Open+begin popup when clicked in void (where there are no windows).
|
||||
#[doc(alias = "BeginPopupContextVoid")]
|
||||
pub fn begin_popup_context_void<Label: AsRef<str>>(
|
||||
&self,
|
||||
str_id: Label,
|
||||
) -> Option<PopupToken<'_>> {
|
||||
let render = unsafe {
|
||||
sys::igBeginPopupContextWindow(
|
||||
self.scratch_txt(str_id),
|
||||
imgui_sys::ImGuiPopupFlags_MouseButtonRight as i32,
|
||||
)
|
||||
};
|
||||
|
||||
if render {
|
||||
Some(PopupToken::new(self))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
create_token!(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user