Extended the event driven window manager to handle a windowed screen with multiple control windows
isn't complete yet or extensively debugged and not sure if #PB_Event_DeactivateWindow is present on windows
Events are registered with a precedence
1 a specific gadget and event "OnClick" ...
2 a specific gadget or any gadget and all its events via "Onevent"
1 a specific window and event "OnWindowMaximize"
2 a specific window or any window and all its gadgets events via "OnEvent"
1 a WindowScreen callback for rendering
keyboard functions replace PB keyboard (*don't use pb InitKeyboard)
US english keyboard is currently text mapped scan includes lowercase keys
ClassWindowKeyboardPressed(windowObject,#OPBKey_UP) to test for multiple key presses
ClassWindowKeyboardReleased(windowObject,#OPBKey_DOWN)
key = ClassWindowGetKey(windowobject) ;gets the current key pressed down
keyString = ClassWindowGetKeyString(key) ;converts the key to it's string (needs to be language mapped)
[edit]
Added MouseScroll events
Fixed a few bugs
Code:
Procedure Window2_OK_OnClick()
;...
Endprocedure
w2 = NewWindow("w2",0,0,300,200,"Window2",#PB_Window_ScreenCentered)
wn2 = ClassWindowGetWindowNumber(w2)
If CreateMenu(0,ClassWindowGetWindowID(w2))
MenuTitle("Project")
MenuItem(1, "Open")
MenuBar()
MenuItem(4, "Close")
EndIf
;register menu callback
ClassWindowRegisterWindowEvent(w2,#OnMenu,@Window2_OnMenu())
;Add a gadget and register a event pass in the gadget ID
b2 = ClassWindowAddGadget(w2,ButtonGadget(#PB_Any,235,5,60,20,"OK"), #OnClick,@Window2_OK_OnClick())
;add additional events for the gadget mouse enter / leave
ClassWindowRegisterGadgetEvent(b2,#OnMouseEnter,@Window2_OK_OnMouseEnter())
ClassWindowRegisterGadgetEvent(b2,#OnMouseLeave,@Window2_OK_OnMouseLeave())
lv2 = ListViewGadget(#PB_Any,3,30,293,160)
;enter the main loop
ClassWindowMain()
;program will end when all window are closed