* 650 Posts in 228 Topics by 68 Members Latest Member: takis76   **
IFSO PORTAL
  Advanced search
May 17, 2012, 06:59:12 pm
HomeforumHelpSearchLoginRegister**
Recent Posts
[May 05, 2012, 01:01:38 pm]

[May 03, 2012, 02:11:03 pm]

[April 30, 2012, 12:48:25 pm]

[April 30, 2012, 12:46:52 pm]

[March 02, 2012, 02:05:01 pm]

[February 01, 2012, 07:03:43 pm]

[January 10, 2012, 09:50:03 pm]

[November 06, 2011, 02:57:54 pm]

[November 05, 2011, 08:11:39 pm]

[November 03, 2011, 12:09:02 pm]
IFSO Portal  |  Forum  |  ifsoGUI  |  ifsoGUI Discussion  |  Topic: Passing userdata to callbacks « previous next »
Pages: [1] Go Down Print
Author Topic: Passing userdata to callbacks  (Read 4956 times)
Htbaa
ifsoGUI Owner
Newbie
*
Offline Offline

Posts: 7



View Profile
« on: October 25, 2009, 11:35:34 am »

A neat feature for me would be that when using callbacks I'd have the possibility to pass userdata (of the type Object) to the callback.

Something like this:

Code:
SetCallBack(func(gadget:ifsoGUI_Base, id:Int, data:Int, iMouseX:Int, iMouseY:Int, userData:Object), userData:Object = Null)

So when doing this:

Code:
Local stream:TStream 'Just an example, could be anything
window.SetCallBack(myCallBack, stream)

I'd be able to work on the stream data passed to the callback. Why would I need this? Well, imagine an editor of some sort. About 10 gameobjects of the same type are on screen, clicking on them opens a window which allows me to edit properties of the object directly. For all I care for every object a property window could be open. When doing this I figure I can't use the "traditional" event queue. So when using callbacks I'd like to pass this object to the callback so I can modify it from the callback.

I understand this changes the callbacks' signature which can be a pain for those who are already using it. However, it does enable you to directly interact with an object and gives great flexibility.
Logged
TaskMaster
Administrator
Sr. Member
*****
Offline Offline

Posts: 450


TaskyZ
View Profile
« Reply #1 on: October 25, 2009, 05:13:15 pm »

I do a similar thing with my editor where events are passed and I want them act on a selected gadget.  But, I just keep track of the selected gadget.

I bet you could cheat and get the address of your object and put it into the data field (integer).  Then, in your callback function, convert that integer back to an object address.
Logged
Htbaa
ifsoGUI Owner
Newbie
*
Offline Offline

Posts: 7



View Profile
« Reply #2 on: October 26, 2009, 01:41:51 pm »

But when using HandleFromObject() I have to manually call Release on it afterwards, which is not what I want. It's going to be a pain to manage all those memory pointers. So I prefer an extra parameter of the type Object that can be used to pass userdata.
Logged
TaskMaster
Administrator
Sr. Member
*****
Offline Offline

Posts: 450


TaskyZ
View Profile
« Reply #3 on: October 27, 2009, 08:05:16 am »

OK, just got to thinking about this a little more.

You are setting the object to be passed for the Window's callbacks.  You could easily just put that stream in the window's property tree using SetProperty.

Then when you get an event, just use GetProperty to get the Window's stream.
Logged
Htbaa
ifsoGUI Owner
Newbie
*
Offline Offline

Posts: 7



View Profile
« Reply #4 on: October 27, 2009, 11:32:06 am »

I think that'll do :-) Didn't knew it existed, haha.
Logged
TaskMaster
Administrator
Sr. Member
*****
Offline Offline

Posts: 450


TaskyZ
View Profile
« Reply #5 on: October 27, 2009, 01:08:23 pm »

I think that'll do :-) Didn't knew it existed, haha.

It was added in v1.05.  I think it was requested by Samah.
Logged
Htbaa
ifsoGUI Owner
Newbie
*
Offline Offline

Posts: 7



View Profile
« Reply #6 on: October 27, 2009, 02:12:35 pm »

I've only be using ifsoGUI since 1.11 Tongue

A big-ish problem for me is that most documentation is on the wiki. Not that the wiki is a bad format, but I'm used to have the documentation BlitzMax style like the rest of the BlitzMax modules. I wonder though, isn't it a bit of a pain to keep the wiki up to date with the modules?
Logged
TaskMaster
Administrator
Sr. Member
*****
Offline Offline

Posts: 450


TaskyZ
View Profile
« Reply #7 on: October 27, 2009, 02:21:57 pm »

I've only be using ifsoGUI since 1.11 Tongue

A big-ish problem for me is that most documentation is on the wiki. Not that the wiki is a bad format, but I'm used to have the documentation BlitzMax style like the rest of the BlitzMax modules. I wonder though, isn't it a bit of a pain to keep the wiki up to date with the modules?

Yeah, but I figured people would want it.  Since it is done, all I have to do is update it for the small changes that get made, so not that big of a deal.

What would need to be done to the ifsoGUI source to make it do BlitzMax documentation style?
Logged
Htbaa
ifsoGUI Owner
Newbie
*
Offline Offline

Posts: 7



View Profile
« Reply #8 on: October 27, 2009, 02:48:37 pm »

For example you might want to take a look at one of my modules: http://github.com/Htbaa/xmlrpc.mod
If you put a intro.bbdoc (http://github.com/Htbaa/xmlrpc.mod/blob/master/doc/intro.bbdoc) in the doc folder of every module (extended gadgets) then you could put  specific module info in there, just like you do on the wiki.

I'm not saying you should move the documentation to it, but it would be neat if it was included. The biggest pro is that documentation will be automatically generated. I'm not sure how these wiki's work (I never tried editing a page) but keeping it all together seems like a lot of work. But then again, most of it is in it already :-).
Logged
TaskMaster
Administrator
Sr. Member
*****
Offline Offline

Posts: 450


TaskyZ
View Profile
« Reply #9 on: October 27, 2009, 03:01:32 pm »

For example you might want to take a look at one of my modules: http://github.com/Htbaa/xmlrpc.mod
If you put a intro.bbdoc (http://github.com/Htbaa/xmlrpc.mod/blob/master/doc/intro.bbdoc) in the doc folder of every module (extended gadgets) then you could put  specific module info in there, just like you do on the wiki.

I'm not saying you should move the documentation to it, but it would be neat if it was included. The biggest pro is that documentation will be automatically generated. I'm not sure how these wiki's work (I never tried editing a page) but keeping it all together seems like a lot of work. But then again, most of it is in it already :-).


The ifsoGUI source has the bbdoc: and about: stuff in it already.  Does there have to be a intro.bbdoc file?  Is that all that is missing?
Logged
Htbaa
ifsoGUI Owner
Newbie
*
Offline Offline

Posts: 7



View Profile
« Reply #10 on: October 27, 2009, 04:05:10 pm »

Only for every gadget/module I suppose. Each gadget has it's own events ImageButton uses others than FileSelect for example. This is the kind of stuff that could go into a module specific intro.bbdoc.

In the intro.bbdoc for ifsogui.gui I'd mention the events as described here: http://wiki.ifsogui.com/index.php/Events. Or use bbdoc also on constants so they show up in the documentation. Like this:
Code:
Rem
bbdoc: Event mouse down
End Rem
Const ifsoGUI_EVENT_MOUSE_DOWN:Int = 7

My IDE (BLIde) pops them up with auto-complete but not all IDE's have that. And when no internet connection is available checking a Wiki is going to be though.
Logged
TaskMaster
Administrator
Sr. Member
*****
Offline Offline

Posts: 450


TaskyZ
View Profile
« Reply #11 on: October 27, 2009, 05:59:56 pm »

Hmmm, I think it will take a bit more understanding of the bbdoc system.  I will add it to my todo list.

If life would quit getting in the way, I could get some of this stuff done.  Smiley
Logged
TaskMaster
Administrator
Sr. Member
*****
Offline Offline

Posts: 450


TaskyZ
View Profile
« Reply #12 on: November 19, 2009, 10:22:41 am »

All of the modules now create documentation.  99% of the Functions/Methods are documented.  There could be some more documentation in some of the files, but what we have now is better than nothing.  Smiley
Logged
Corum
ifsoGUI Owner
Newbie
*
Offline Offline

Posts: 37


CoRuMmO
View Profile
« Reply #13 on: November 19, 2009, 12:48:24 pm »

All of the modules now create documentation.  99% of the Functions/Methods are documented.  There could be some more documentation in some of the files, but what we have now is better than nothing.  Smiley
Uh?! Maybe written in the wrong thread, but sweet news anyway!
Waiting for updated library files.
Cheers! Smiley

EDIT: Oops. You were talking about wiki docs. Sorry. Tongue
« Last Edit: November 19, 2009, 01:12:11 pm by Corum » Logged
Pages: [1] Go Up Print 
IFSO Portal  |  Forum  |  ifsoGUI  |  ifsoGUI Discussion  |  Topic: Passing userdata to callbacks « previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines
TinyPortal v0.9.8 © Bloc
TechHead design by Bloc
Valid XHTML 1.0! Valid CSS!