What's the tGadget Context field for?

BlitzMax Forums/BlitzMax Programming/What's the tGadget Context field for?

Gabriel(Posted 2006) [#1]
I see people using it for their own purposes, and I'd like to do the same, but I have no clue if or when MaxGUI might be using this field itself, so I can't predict whether my use of it will be broken.

What's it for? Does MaxGUI use it? Is it safe to hijack it for my own purposes?


Dreamora(Posted 2006) [#2]
I haven't found any case where anything seems to be in so far.

MaxGUI uses TEvent.source to tell what fired it instead.

If you want to go save, use TEvent.extra btw ... thats a field for "user interaction"


Gabriel(Posted 2006) [#3]
I'm looking for something I can use with TreeViews though. The extra field in that case is already occupied, because the TreeViewNode is the Extra field. What I'm wanting ( because the TreeView gadget is wholly inadequate IMO ) is to tie each node to a custom object on my own "treemap" data type. So I'm looking for a field I can tie that into.

Is it safe for me to put this in the Context field of a tGadget or is that going to break my code and force me to have to rewrite hundreds of lines of code way down the line? Is there another fields I can use instead? I noticed that using the Context field to store stuff in TreeViewGadgets in the MaxGUI tutorials, but since BRL don't write the tutorials and haven't documented the field, nor is there any unbuilt way to make TreeView gadgets useful, I'm kinda stuck between a rock and a hard place here.


tonyg(Posted 2006) [#4]
Skid used it in his example here so should be OK to use.


Gabriel(Posted 2006) [#5]
Aha, so he did. Thanks for that. I tried a forum search last night, but that didn't come up.


skidracer(Posted 2006) [#6]
Except that was obviously Assari's code.

To answer your question context is already used by SetGadgetFilter. It is for the same type of association so yes SetGadgetContext() and EventContext() functions I suppose could be added to make it officially usable.

I personally would use a map that uses treeviewnode,yourdataobject as the key,value pair and do a single look up at the start of the treeview event handler that resolves your issue.