Found an issue in SpiderBasic ? Please report it here !
User avatar
Paul
 
Posts: 97
Joined: Wed Feb 26, 2014 6:46 pm
Location: Canada

Issues with Creating and Freeing PopupMenu

by Paul Mon May 25, 2020 10:28 pm

The following code creates a Window with a Button. Press the Button to hide the current Window and create a new Window with a PopupMenu and the Debugger displays "OK".
If you Close the Window the debugger displays "CLOSE", then press the Button to create a new Window again, the PopupMenu is no longer created and the Debugger will not display "OK".

Also if you uncomment the code to Free the PopupMenu, the new Window will no longer Close and the debugger will not display "CLOSE"


Code: Select all
Enumeration 1
  #Window_Main
  #Window_Win2
EndEnumeration

Enumeration 1
  #Gadget_Main_Win2
  #Gadget_Win2_Close
  #Pop
  #Pop_Test
EndEnumeration


Procedure.i Window_Win2()
  If OpenWindow(#Window_Win2,0,0,289,140,"Window 2",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
    If CreatePopupMenu(#Pop)
      Debug "POPUP Created"
      MenuItem(#Pop_Test,"Test Popup")   
    EndIf
   
    Debug "OK"
    ProcedureReturn WindowID(#Window_Win2)
  EndIf
EndProcedure


Procedure CloseWindowEvent()
  If EventWindow()=#Window_Win2
    ;FreeMenu(#Pop) ;<----- Program Stops Working if FreeMenu used
    Debug "CLOSE"
    CloseWindow(#Window_Win2)
    HideWindow(#Window_Main,#False)
  EndIf
EndProcedure

Procedure GadgetEvent()
  If EventGadget()=#Gadget_Main_Win2
    HideWindow(#Window_Main,#True)
    Window_Win2()
  EndIf   
EndProcedure

If OpenWindow(#Window_Main,0,0,400,300,"Main Window",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
  ButtonGadget(#Gadget_Main_Win2,260,230,115,40,"Window 2")
  BindEvent(#PB_Event_Gadget,@GadgetEvent())
  BindEvent(#PB_Event_CloseWindow,@CloseWindowEvent())
EndIf
Return to Bugs Reports

Who is online

Users browsing this forum: No registered users and 3 guests