ScrollPanel and EventHooks
BlitzMax Forums/MaxGUI Module/ScrollPanel and EventHooks
| ||
I am making a program that so far has two EventHooks. One called MainHook for basic window stuff and the next is MenuHook for WindowMenu stuff. This is what the MainHook looks similar to: Function testHook:Object(id:Int, data:Object, context:Object) Local event:TEvent = TEvent(data) If (Not event) Return data Select event.id Case EVENT_GADGETACTION Return Null Case EVENT_WINDOWMOVE Return Null Case EVENT_WINDOWSIZE Return Null Case EVENT_WINDOWACTIVATE Return Null Case EVENT_WINDOWCLOSE Select event.source Case mainWindow End EndSelect EndSelect Return data EndFunction I return null on some of these because I don't need the events going through every hook I eventually add. I noticed that when I added a ScrollPanel, upon resizing the window, the V&H scrolls were not updating and remained the same position and size. Returning Null on 'EVENT_WINDOWSIZE' was the culprit. What am I supposed to do to allow ScrollPanel to update itself without having to go through every hook I add? Example Code: TLDR: EventHooks can't return null for EVENT_WINDOWSIZE because it messes up ScrollPanel - but I don't want it to go through every single hook. What should I do? |
| ||
Hello, upon looking at scrollpanel.bmx source it creates eventhook with priority -1 to handle sizing. In your source eventhook priority is higher (by default) so when your mainhook returns null the scrollpanel eventhook is never executed, hence nothing happens. One way would be to alter priority of hooks so that scrollpanelhook is executed first, but I'm not sure if your original setup is going to be a problem in performance wise. EDIT: So this... AddHook EmitEventHook, testHook AddHook EmitEventHook, printHook ...would be changed to this AddHook EmitEventHook, testHook, Null, -2 AddHook EmitEventHook, printHook, Null, -3 -Henri |
| ||
Thanks a ton Henri! :) |