new ToolTip vs. defaultToolTip for buttons not working as expected

Discuss coding questions, pull requests, and implementation details.
Post Reply
User avatar
Nystul
Posts: 1394
Joined: Mon Mar 23, 2015 8:31 am

new ToolTip vs. defaultToolTip for buttons not working as expected

Post by Nystul » Fri Sep 21, 2018 3:01 pm

I found - what I think is a issue with ToolTip class and Button (not TextLabel - there ToolTip works as expected):

this works (tool tip shows on hover over button):

Code: Select all

            buttonToolTip = defaultToolTip;
            buttonToolTip.Parent = NativePanel;
            aButton = DaggerfallUI.AddButton(new Rect(78, 171, 27, 19), NativePanel);
            aButton.ToolTip = buttonToolTip;
            aButton.ToolTipText = "this is a tool tip";
this does not (tool tips never show up - it seems that in function BaseScreenComponent.Draw the value mouseOverComponent is always false for some reason):

Code: Select all

            buttonToolTip = new ToolTip();
            buttonToolTip.CloneSettings(defaultToolTip);
            buttonToolTip.Parent = NativePanel;
            aButton = DaggerfallUI.AddButton(new Rect(78, 171, 27, 19), NativePanel);
            aButton.ToolTip = buttonToolTip;
            aButton.ToolTipText = "this is a tool tip";
So basically using defaultToolTip does work, using a custom tooltip does not work.
As mentioned above TextLabel class allows custom ToolTips to be used.

Is this a bug or am I doing something wrong?

User avatar
Interkarma
Posts: 5183
Joined: Sun Mar 22, 2015 1:51 am

Re: new ToolTip vs. defaultToolTip for buttons not working as expected

Post by Interkarma » Fri Sep 21, 2018 11:22 pm

Check out the HUDActiveSpells class for an example of creating a custom ToolTip instance within a Panel (HUDActiveSpells is derived from Panel, just like Button). It's still called "defaultToolTip", but that's just my naming - it's a whole new tip instance just for those panels.

The trick with your custom ToolTip is that it has to receive Update() and Draw() calls. When using DaggerfallBaseWindow, the default tooltip instance is updated and drawn for you. So any controls using it will "just work".

If you decide to make your own tooltip instance, you need to feed it updates and tell it when to draw. This gives you full control over the custom tooltip.

Post Reply