I'm building a multieditor application (as many others already did) based on the Scintilla gadget. One thing I'd like to do is to open a secondary window where the user can add some text metadata (so far nothing new). Everything works fine until... to my surprise, once I've opened any secondary window I can no longer create a new Scintilla gadget!
What follows is a testbed To demonstrate this behavior. You can press "Make Sci" as many times as you wish. The editors are created as expected and reported in the debug window. Press "Open win" to briefly open a (empty) window and then close it right back. The next time you press "Make Sci" the ScintillaGadget function returns 0 and the gadget is not created.
Any thoughts on this? I'd really appreciate it.
Code: Select all
EnableExplicit
InitScintilla()
#mainWin = 0
#subWin = 1
#mkSciBtn = 1
#opWinBtn = 2
Procedure DoSciCallback(i, *scinotify.SCNotification)
EndProcedure
Procedure TestSci(sciNum)
If sciNum > 0
Debug "Created sci# "+Str(sciNum)
Else
Debug "** Sci not created **"
End
EndIf
EndProcedure
Procedure MakeSci()
Protected sciNum
sciNum = ScintillaGadget(#PB_Any, 100, 0, WindowWidth(#mainWin)-100, WindowHeight(#mainWin), @DoSciCallback())
TestSci(sciNum)
EndProcedure
Procedure OpenSubWin()
DisableWindow(#mainWin, #True)
OpenWindow(#subWin, 0, 0, 300, 300, "secondary Window!", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
EndProcedure
Procedure CloseSubWin()
CloseWindow(#subWin)
DisableWindow(#mainWin, #False)
EndProcedure
;
; Main
;
OpenWindow(#mainWin, 0, 0, 600, 700, "Main Window!", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ButtonGadget(#mkSciBtn, 0, 10, 100, 20, "Make sci")
ButtonGadget(#opWinBtn, 0, 40, 100, 20, "Open win")
BindGadgetEvent(#mkSciBtn, @MakeSci())
BindGadgetEvent(#opWinBtn, @OpenSubWin())
Define event, window
Repeat
event = WaitWindowEvent()
window = EventWindow()
Select window
Case #subWin
If event = #PB_Event_CloseWindow
CloseSubWin()
EndIf
Case #mainWin
If event = #PB_Event_CloseWindow
End
EndIf
EndSelect
ForEver
End