GEF4 Tooltip [message #1729422] |
Thu, 14 April 2016 05:27 |
|
I would like to add tooltips to my GeometryNodes, for any part where the content model has a non empty name property. This was fairly straightforward in Draw2D, as you just set Figure.setToolTip(IFigure), but it seems like there is more work involved in GEF4.
Following the MVC Logo example I have a delete hover handle that appears after a suitable delay, and I traced that back to FXHoverBehavior. I tried creating an extension of FXHoverBehavior, and although I could get that to display a tool tip label, it obviously wasn't right as there were lots of exceptions getting thrown. It feels like there should be some simple hook to add behaviour that happens after the mouse has hovered for a short while, but I can't work out where. FXHoverTool doesn't seem right either, as it is only triggered by the mouse moving, and you would have to add your own listeners somewhere to detect the actual hovering.
It seems like this is an awful lot of work for something that should be really simple. Am I missing something?
Colin Sharples
CTG Games Ltd
Wellington, New Zealand
|
|
|
Re: GEF4 Tooltip [message #1729443 is a reply to message #1729422] |
Thu, 14 April 2016 08:39 |
|
As you determined correctly, the hover handles are created after a short delay, so the tooltip could be implemented as a hover handle (e.g. TooltipHoverHandlePart). You would need to create that handle part within the HoverHandlePartFactory, but extending the FXHoverBehavior should not be necessary. However, you can also add a tooltip using JavaFX as follows (which is much more convenient):
public class SomePart ... {
private Tooltip tooltip = new Tooltip("tooltip-text");
// ...
protected Group createVisual() {
// ...
Tooltip.install(group, tooltip);
return group;
}
//...
public doRefreshVisual(Group visual) {
// ...
tooltip.setText(getContent().getTooltip());
}
}
Additionally, you could also create your own CustomHoverBehavior that reacts to HoverModel changes and performs some action after a delay if necessary.
Regards,
Matthias
[Updated on: Thu, 14 April 2016 08:41] Report message to a moderator
|
|
|
Re: GEF4 Tooltip [message #1729503 is a reply to message #1729443] |
Thu, 14 April 2016 19:00 |
|
D'oh! I thought there had to be a simple way. I'm learning GEF4 and JavaFX at the same time, so I'm never sure if the thing I'm looking for should be in GEF4 or JavaFX. Thanks again.
Colin Sharples
CTG Games Ltd
Wellington, New Zealand
|
|
|
Powered by
FUDForum. Page generated in 0.03926 seconds