Event Proccessing Questions
BlitzMax Forums/BlitzMax Programming/Event Proccessing Questions
| ||
Hey all, I've been playing around with tree views and ran into something I don't really understand. Would appreciate some help getting my head around it. When a GADGETACTION Event is called from a treeview, the EventData() is the treeViewNode that the user clicked on. I worked this out looking through the source of the MaxIDE. What I don't understand is how EventData() is being converted to a Gadget. Passing EventData() through a Function argument will convert it. eg Function Convert:tGagdet (data:tGadget) Return data End Function Local thing:tGadget = Convert(EventData()) Notify thing.text 'etc I would have thought you could somehow simply typecast the EventData() something like this.. local thing:tGadget = tGadget(EventData()) Can any of you programmers out there explain why passing it through a function works and perhaps suggest a cleaner method of converting the EventData to a Gadget. Any help much appreciated. |
| ||
I have the feeling you've been bitten by the automatic int -> object conversion, and that the fact that the EventData() -> TGadget yielded a valid tgadget is puerly coincidence. Needless to say this isn't reliable. I have barely started to toy with MaxGui, but I think the source gadget can be retrieved from the 'source' field of the event object. |
| ||
local thing:tGadget=SelectedTreeViewNode(Treeview) i tore my hair on this one for quite a while. Is that what you needed? |
| ||
Koriolis: The EventData()->tGadget is how the current IDE interprets messages from the tree view. Space Guy: Thanks for the tip, I did see the function and was using it for a while, I just thought it would be "more correct" to read the data coming out of the event. |