I'm still trying to wrap my head around PB. So far, I am very pleased with it.
I seem to have hit a wall here though: In a multi-Scintilla scenario and a TabBarGadget as "switcher", where do I trap the RightClick event? In my app I use this event to start a spellcheck where the caret is. It works fine when I have only one Scintilla instance... Any ideas?
Here is a testbase to illustrate the situation:
Code: Select all
XIncludeFile "TabBarGadget.pbi"
EnableExplicit
#main = 0
#tabs = 999
#sci = 1000
Procedure DoRightClick()
  Debug "[RightClick]"
EndProcedure
Procedure UpdateTabs()
  Protected i, tabSel, sciNum
  tabSel = GetTabBarGadgetItemPosition(#tabs, #TabBarGadgetItem_Selected)
  For i=0 To CountTabBarGadgetItems(#tabs)-1
    sciNum = #sci+i
    If tabSel = i
      HideGadget(sciNum, #False)
      SetActiveGadget(sciNum)
      BindGadgetEvent(sciNum, @DoRightClick(), #PB_Event_RightClick) ; <----- No good.
    Else
      UnbindGadgetEvent(sciNum, @DoRightClick(), #PB_Event_RightClick) ; <----- Maybe no good.
      HideGadget(sciNum, #True)
    EndIf
  Next
EndProcedure
Procedure CreateNewSci()
  Protected tabPos, sciNum, tabName.s
  tabName = "New " + Str(CountTabBarGadgetItems(#tabs)+1)
  tabPos = AddTabBarGadgetItem(#tabs, #PB_Default, tabName)
  sciNum = #sci+tabPos
  ScintillaGadget(sciNum, 0, GadgetHeight(#tabs), WindowWidth(#main), WindowHeight(#main)-GadgetHeight(#tabs), 0)
  SetActiveGadget(sciNum)
  SetTabBarGadgetState(#tabs, tabPos)
EndProcedure
Procedure DoGadgetEvent()
  Select EventType()
    Case #TabBarGadget_EventType_Change
      UpdateTabs()
    Case #TabBarGadget_EventType_NewItem
      CreateNewSci()
  EndSelect
EndProcedure
OpenWindow(#main, 0, 0, 600, 700, "MultiSciTest", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
TabBarGadget(#tabs, 0, 0, WindowWidth(#main), #TabBarGadget_DefaultHeight, #TabBarGadget_NoTabMoving | #TabBarGadget_NewTab, #main)
InitScintilla()
CreateNewSci()
BindGadgetEvent(#tabs, @DoGadgetEvent())
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
End
Peace.
Ricardo


