On Jun 18, 2008, at 7:02 AM, Annick Fron wrote:
> Hi,
>
> I would just like to associate a tooltip to a visual part and being
> able to change it dynamically.
>
> Can I use something like :
>
> postBuildWith: builder
> (builder componentAt: #myComponent) tooltip: [^self computeString]
I think you need to put a widget in there, or use the widgetAt: API.
You don't need the ^ either. So either
(builder componentAt: #myComponent) widget tooltip: [self
computeString].
or
(self widgetAt: #myComponent) tooltip: [self computeString]
A couple of extra permutations that might be of interest...
You do not have to put a string alone in there. You can return any
sort of VisualComponent. You can wrap it with a block computation or
put that in computeString.
(self widgetAt: #myComponent) tooltip: [self computeTooltip]
computeTooltip
^ToolbarIconLibrary visualFor: #copy
Or you can do it directly if you didn't want it dynamic:
(self widgetAt: #myComponent) tooltip: (ToolbarIconLibrary visualFor:
#copy)
When/if you decide to use a block, the block can be 0 or 1 arg (we
call this block a "culled" block). If it has an arg, it is the view
object of the originating tooltip. So you can do this:
(self widgetAt: #myComponent) tooltip: [:view | view topComponent label]
This last example will use whatever is the label of your window as the
tooltip (not very useful itself, but illustrative of the fact that it
is dynamic (computed) and has access to the view object which is often
a good starting point to derive dynamic tooltips.
Happy tipping. :)
--
Travis Griggs
Objologist
What's next, Intel Processors branded with "Apple Outside" stickers?
_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc