On 2011-07-11 13:45, Mathieu Bouchard wrote:
On Mon, 11 Jul 2011, Martin Peach wrote:
On 2011-07-11 12:06, Jonathan Wilkes wrote:
But I'm not sure where to store the tooltip string...
Not sure if that's what you mean, but in max the assist method receives a number corresponding to the inlet or outlet and returns a pointer to the appropriate string, so the string is already stored somewhere in the memory allocated to the object.
Not necessarily : the assist-method could be storing the data anywhere, or generating it on-the-fly from whatever.
OK, but the object is responsible for knowing where it is, not Pd. If the string is generated on-the-fly or stored elsewhere the object will have allocated the memory for it.
In theory, tooltip strings could be stored in something at the class-level instead of the object-level, just like methods called at the object-level refer to a method-table stored at the class-level.
That is indeed what happens: a shared library has a section for strings (or "data"). Unless it is generating them on-the-fly, each instance of the class will refer to the same location in memory for its strings.
But Pd doesn't allow extending struct t_class by externals, and it doesn't have a tooltip field (except GÃŒnter's tooltip diff included a field for storing a symbol containing the text of the left-inlet's text... and only that).
I don't see a need to extend any structs, Pd just needs to call an object's assist method whenever the mouse is hovering over one of its inlet/outlets, and display the returned string inside a box. If there is no assist method, then Pd would use a default string from its own class, depending on what types were registered to that inlet/outlet at creation time.
Martin