added openPopupOnItemClick (#133)

This commit is contained in:
Nicole Dresselhaus 2022-02-25 18:28:53 +01:00 committed by GitHub
parent 67e169dc35
commit b837d583a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 0 deletions

View File

@ -245,6 +245,7 @@ module DearImGui
, Raw.endPopup , Raw.endPopup
, openPopup , openPopup
, openPopupOnItemClick
, Raw.closeCurrentPopup , Raw.closeCurrentPopup
-- * Item/Widgets Utilities -- * Item/Widgets Utilities
@ -1486,6 +1487,17 @@ openPopup :: MonadIO m => String -> m ()
openPopup popupId = liftIO do openPopup popupId = liftIO do
withCString popupId Raw.openPopup withCString popupId Raw.openPopup
-- | Opens a defined popup (i.e. defined with 'withPopup') on defined action.
--
-- Example:
--
-- > openPopupOnItemClick "myPopup" ImGuiPopupFlags_MouseButtonRight
--
-- Wraps @ImGui::OpenPopup()@
openPopupOnItemClick :: MonadIO m => String -> ImGuiPopupFlags -> m ()
openPopupOnItemClick popupId flags = liftIO do
withCString popupId $ \popupId' -> Raw.openPopupOnItemClick popupId' flags
withCStringOrNull :: Maybe String -> (Ptr CChar -> IO a) -> IO a withCStringOrNull :: Maybe String -> (Ptr CChar -> IO a) -> IO a
withCStringOrNull Nothing k = k nullPtr withCStringOrNull Nothing k = k nullPtr

View File

@ -197,6 +197,7 @@ module DearImGui.Raw
, beginPopupModal , beginPopupModal
, endPopup , endPopup
, openPopup , openPopup
, openPopupOnItemClick
, closeCurrentPopup , closeCurrentPopup
-- * ID stack/scopes -- * ID stack/scopes
@ -1252,6 +1253,13 @@ openPopup :: (MonadIO m) => CString -> m ()
openPopup popupIdPtr = liftIO do openPopup popupIdPtr = liftIO do
[C.exp| void { OpenPopup($(char* popupIdPtr)) } |] [C.exp| void { OpenPopup($(char* popupIdPtr)) } |]
-- | Call to mark popup as open (don't call every frame!).
--
-- Wraps @ImGui::OpenPopupOnItemClick()@
openPopupOnItemClick :: (MonadIO m) => CString -> ImGuiPopupFlags-> m ()
openPopupOnItemClick popupIdPtr flags = liftIO do
[C.exp| void { OpenPopupOnItemClick($(char* popupIdPtr), $(ImGuiPopupFlags flags)) } |]
-- | Manually close the popup we have begin-ed into. -- | Manually close the popup we have begin-ed into.
-- --