I checked and while I do have modal popup, the user is able to click menus and see them, but they do nothing. User can also minimize the main window, but can't close it until the modal is closed.
And I do use createGadgetFromWindow() this way without menu/gadget problems:
resetMainWindow
WinGadgets.mainWin = createGadgetFromWindow(mainWindow())
Warning: I'm going to throw a lot of code at you, sorry.
My main loop once all the gadgets are set up:
function eventLoop()
local t# as float
_exitEditor = FALSE
initTimer()
repeat
t# = hitimer()
repeat
getEvent
processEvent()
` process all the events
until eventType()=0
` only process so many events, as to not cause potential display issues ??
`until ((eventType()=0) or (t#+20 < hitimer()))
updateTimer()
processDBProEvents()
updateDisplay()
showSprites()
drawGrid()
drawOverlay()
hideSprites()
drawDebugText()
sync
until _exitEditor = TRUE
endfunction
My process event function with lots of code removed:
` This function gets called after a getEvent call for BlueGUI
` It will handle all events and send messages to specific gadgets
function processEvent()
local eType as integer
local source as integer
local eData as integer
local eDataEx as integer
local but as integer
eType = eventType()
source = eventSource()
eData = eventData()
eDataEx = eventDataEx()
` Catch modal window here and restrict all events to it
if ModalWindow.gadget <> 0
` reset its focus if necessary
if (activeGadget() <> ModalWindow.gadget) and (getParentGadget(activeGadget()) <> ModalWindow.gadget)
activateGadget ModalWindow.gadget
setGadgetEnabled WinGadgets.mainPanel, FALSE
exitfunction
endif
` Process modal specific event and exit this function
processModalEvent(eType, source, eData)
exitfunction
endif
` If come back from modal window, need to reactivate the main panel
if getGadgetEnabled(WinGadgets.mainPanel) = FALSE
setGadgetEnabled WinGadgets.mainPanel, TRUE
endif
` Check the editor for messages on the main panel
` Do special checks here based on gadget type
select eType
case MOUSE_CLICK:
endcase
case LEFTBUTTON_UP:
endcase
case MENU_CLICK:
processMenuClick(eData, eDataEx)
endcase
case WINDOW_CLOSE:
endcase
case KEYDOWN:
endcase
case KEYUP:
endcase
endselect
endfunction
My processMenuClick function with lots of code removed:
function processMenuClick(eData as integer, eDataEx as integer)
select eData
case HELP_ABOUT:
beginModalHelp()
endcase
case FILE_NEW:
endcase
case FILE_EXIT:
endcase
case FILE_OPEN:
endcase
case FILE_SAVE:
endcase
case FILE_SAVEAS:
endcase
case EDIT_UNDO :
endcase
case EDIT_REDO :
endcase
endselect
endfunction
And some modal functions...
remstart
===============================================================================
EditorModal.dba
This module contains all the code dealing with Modal windows and the
maintenance and interaction with them
===============================================================================
remend
function processModalEvent(eType as integer, source as integer, eData as integer)
` Do checks here for modal window messages
select eType
case MOUSE_CLICK :
processModalClick(source, eData)
endcase
case MOD_EV_UPDATE :
updateModal(source, eData)
endcase
case WINDOW_CLOSE :
` This should always match... but check anyway?
if ModalWindow.gadget = source
deleteModalGadgets()
endif
endcase
endselect
endfunction
function sendModalEvent(eType as integer, eData as integer)
if ModalWindow.gadget > 0
postEvent ModalWindow.gadget, eType, eData, 0
else
errorMessage "Illegal Modal Event: No ModalWindow active!"
endif
endfunction
function deleteModalGadgets()
local ctr as integer
` Delete all the gadgets on the modal window
for ctr = 1 to MAX_MODAL_GADGETS
if ModalGadgets(ctr).gadgetNum <> 0
ModalGadgets(ctr).gadgetNum = deleteGadget(ModalGadgets(ctr).gadgetNum)
ModalGadgets(ctr).gadgetType = GADGET_NONE
ModalGadgets(ctr).gadgetName$ = ""
ModalGadgets(ctr).enabled = FALSE
endif
next ctr
ModalWindow.gadget = deleteGadget(ModalWindow.gadget)
ModalWindow.modalType = MODAL_NONE
endfunction
` This function will handle all common initialization that needs to be done
` It should be placed at the beginning of any modal creation functions
function beginModal()
` Disable the main panel
setGadgetEnabled WinGadgets.mainPanel, FALSE
endfunction
function modalFindCenterX(width as integer)
local xCoord as integer
xCoord = gadgetX(WinGadgets.mainWin) + (gadgetWidth(WinGadgets.mainWin) / 2)
dec xCoord, (width / 2)
endfunction xCoord
function modalFindCenterY(height as integer)
local yCoord as integer
yCoord = gadgetY(WinGadgets.mainWin) + (gadgetHeight(WinGadgets.mainWin) / 2)
dec yCoord, (height / 2)
endfunction yCoord
function getModalGadgetNum(name$ as string)
local num, ctr as integer
for ctr = 1 to MAX_MODAL_GADGETS
if ModalGadgets(ctr).gadgetName$ = name$
num = ModalGadgets(ctr).gadgetNum
exitfunction num
endif
next ctr
endfunction 0
function processModalClick(source as integer, eData as integer)
local name$ as string
local ctr as integer
name$ = ""
` Find the gadget that was clicked
for ctr = 1 to MAX_MODAL_GADGETS
if ModalGadgets(ctr).gadgetNum = source then name$ = ModalGadgets(ctr).gadgetName$
next ctr
` Shouldn't happen, but who knows?
if name$ = "" then exitfunction
` This is where logic for all the different modal windows comes into play
select ModalWindow.modalType
case MODAL_HELPABOUT:
processHelpClick(name$, eData)
endcase
endselect
endfunction
` Not sure what use we have of this now but keep it around for now
function updateModal(source as integer, eData as integer)
select ModalWindow.modalType
case MODAL_HELPABOUT:
endcase
endselect
endfunction
` HELP ABOUT
` -------------------------------------------------------------------------------------------------
function beginModalHelp()
local width, height as integer
beginModal()
width = 300
height = 200
ModalWindow.gadget = createWindow(modalFindCenterX(width), modalFindCenterY(height), width, height, "About", WINDOW_FIXED, WINDOW_TOOLWINDOW, 0, 0)
ModalWindow.modalType = MODAL_HELPABOUT
ModalGadgets(1).gadgetNum = createPanel(20, 20, 200, 50, ModalWindow.gadget)
setPanelImage ModalGadgets(1).gadgetNum, DIR_EDITOR_IMAGE + "About.bmp"
ModalGadgets(1).gadgetName$ = "Main Panel"
ModalGadgets(1).gadgetType = GADGET_PANEL
ModalGadgets(2).gadgetNum = createLabel(20, 125, 200, 20, "Version: 0.1 (Alpha)", ModalWindow.gadget)
ModalGadgets(2).gadgetName$ = "Version Label"
ModalGadgets(2).gadgetType = GADGET_LABEL
ModalGadgets(3).gadgetNum = createLabel(20, 145, 200, 20, "Copyright 2010 Funcy Games, LLC", ModalWindow.gadget)
ModalGadgets(3).gadgetName$ = "Version Label"
ModalGadgets(3).gadgetType = GADGET_LABEL
ModalGadgets(4).gadgetNum = createButton(220, 145, 60, 25, "Close", 0, ModalWindow.gadget)
ModalGadgets(4).gadgetName$ = "Close Button"
ModalGadgets(4).gadgetType = GADGET_BUTTON
endfunction
function processHelpClick(name$ as string, eData as integer)
select name$
case "Close Button":
postEvent ModalWindow.gadget, WINDOW_CLOSE, 0, 0
endcase
endselect
endfunction
Hope this helps!

A 3D marble platformer using Newton physics.