@@ -77,6 +77,8 @@ func (c *Context) Window(title string, rect image.Rectangle, f func(layout Conta
7777}
7878
7979func (c * Context ) window (title string , bounds image.Rectangle , opt option , id WidgetID , f func (layout ContainerLayout )) error {
80+ // A window is not a widget in the current implementation, but a window is a widget in the concept.
81+ c .currentID = id
8082 var err error
8183 c .idScopeFromID (id , func () {
8284 err = c .doWindow (title , bounds , opt , id , f )
@@ -234,10 +236,9 @@ func (c *Context) doWindow(title string, bounds image.Rectangle, opt option, id
234236 return nil
235237}
236238
237- func (c * Context ) OpenPopup (name string ) {
238- id := c .idFromGlobalString (name )
239+ func (c * Context ) OpenPopup (widgetID WidgetID ) {
239240 c .wrapError (func () error {
240- cnt := c .container (id , 0 )
241+ cnt := c .container (widgetID , 0 )
241242 // set as hover root so popup isn't closed in begin_window_ex()
242243 c .nextHoverRoot = cnt
243244 c .hoverRoot = c .nextHoverRoot
@@ -253,24 +254,25 @@ func (c *Context) OpenPopup(name string) {
253254 })
254255}
255256
256- func (c * Context ) ClosePopup (name string ) {
257- id := c .idFromGlobalString (name )
257+ func (c * Context ) ClosePopup (widgetID WidgetID ) {
258258 c .wrapError (func () error {
259- cnt := c .container (id , 0 )
259+ cnt := c .container (widgetID , 0 )
260260 cnt .open = false
261261 return nil
262262 })
263263}
264264
265- func (c * Context ) Popup (name string , f func (layout ContainerLayout )) {
266- id := c .idFromGlobalString (name )
265+ func (c * Context ) Popup (f func (layout ContainerLayout )) WidgetID {
266+ pc := caller ()
267+ id := c .idFromCaller (pc )
267268 c .wrapError (func () error {
268269 opt := optionPopup | optionAutoSize | optionNoResize | optionNoScroll | optionNoTitle | optionClosed
269- if err := c .window (name , image.Rectangle {}, opt , id , f ); err != nil {
270+ if err := c .window ("" , image.Rectangle {}, opt , id , f ); err != nil {
270271 return err
271272 }
272273 return nil
273274 })
275+ return id
274276}
275277
276278func (c * Context ) pushContainer (cnt * container ) {
0 commit comments