@sgold said:
Or maybe not. Sometimes the tool tip disappears when I expect it to, and sometimes it doesn't. I may need to look into this some more.
Ok… are the times that it happens and doesn’t happen related to the same methods of hiding or removing (i.e. a bug)? Or is this a situation that I just simply missed something that needs to perform this check?
EDIT: Using this post to test something… ignore the edit!
Status update: The tooltip disappears (as expected) when I hide or remove the button in my test application, but it doesn’t do this in my game. I’m trying to figure out what’s different about my game.
@sgold said:
Status update: The tooltip disappears (as expected) when I hide or remove the button in my test application, but it doesn't do this in my game. I'm trying to figure out what's different about my game.
Let me know if I need to update anything once you determine the difference.
It’s not yet clear to me how mouseFocusElement is supposed to get updated when a button is hidden or removed. It looks to me like the only code in Screen.java which updates mouseFocusElement is line 608, which is in onMouseMotionEvent().
I see you added code to invoke Screen.hideToolTip(), but I don’t see hideToolTip() affecting mouseFocusElement at all.
@sgold said:
I'm trying to understand how the GUI works.
It’s not yet clear to me how mouseFocusElement is supposed to get updated when a button is hidden or removed. It looks to me like the only code in Screen.java which updates mouseFocusElement is line 608, which is in onMouseMotionEvent().
I see you added code to invoke Screen.hideToolTip(), but I don’t see hideToolTip() affecting mouseFocusElement at all.
MouseFocusElement is used for more than just ToolTips (likely why it is not being cleared). Instead of clearing the current mouse focus element (which would cause many issues), it would be best to simply add a check to ensure that the mouse focus element’s absolute parent or the mouse focus element itself is visible:
[java]
if (useToolTips && getApplication().getInputManager().isCursorVisible()) {
if (mouseFocusElement != null) {
if (!mouseFocusElement.getIsVisible() || !mouseFocusElement.getAbsoluteParent().getIsVisible()) // This check here
newText = forcedToolTipText;
else
newText = mouseFocusElement.getToolTipText();
} else {
newText = forcedToolTipText;
}
}
[/java]
This would likely solve any issues you are having with this.
@t0neg0d said:
MouseFocusElement is used for more than just ToolTips (likely why it is not being cleared). Instead of clearing the current mouse focus element (which would cause many issues), it would be best to simply add a check to ensure that the mouse focus element's absolute parent or the mouse focus element itself is visible
I see that mouseFocusElement is used not only for tool tips but also to alter the cursor, to override the 2D framework, and to notify listeners of focus changes. However, it seems to me that updating mouseFocusElement when the element is hidden or removed would resolve more issues than it would create.
It seems to me that when an Element is hidden or removed, the tooltip is not the only thing which needs updating. The cursor and the 2D framework might need updating as well. I suppose it’s debatable whether a hidden or removed element should receive notification of losing focus. However, if hiding or removing an Element exposes some other Element, the newly exposed Element could become the focus and need to update its listeners accordingly.
What issues would be created if you updated the current mouse focus element whenever it gets hidden or removed?
@sgold said:
What issues would be created if you updated the current mouse focus element whenever it gets hidden or removed?
Actually, I have no clue. lol But, that’s likely because I am tired this morning.
I certainly don’t mind giving it a shot and running a bunch of tests to find out.
EDIT: Because your brain is probably working this morning where mine is not… what issues (aside from tooltips) do you see this potentially fixing? It would help me while testing so I can repro the benefits as well as test the existing scenarios I am aware of (or should be if I wasn’t so out of it)
EDIT 2: You brought up an interesting point that is not solved for tooltips by forcing a hide when an element (or parent/absolute parent) is hidden. If you were to show an element, this would not be updated either until the mouse moved. I’m starting to think that certain events (like hide/show) need to fire off ray casting to reset focus.
EDIT 3: Actually, it might be better to provide a user callable reset on focus. That way, when unloading an AppState (for instance) this isn’t fired off 10+ times.
@t0neg0d said:
Actually, I have no clue. lol But, that's likely because I am tired this morning.
I know that feeling!
what issues (aside from tooltips) do you see this potentially fixing? It would help me while testing so I can repro the benefits as well as test the existing scenarios I am aware of (or should be if I wasn't so out of it)
Cursor updates, 2D framework changes, and listener notification all seem connected with mouse focus,
so they should all get tested.
I'm starting to think that certain events (like hide/show) need to fire off ray casting to reset focus.
Tbh, I’m not sure why I didn’t just do this to begin with. I was so focused on not adding this one-time check, even though it is done every time the mouse moves >.< Ever feel like tattooing a bullseye on your forhead to make it easier to slap at moments like these?
@t0neg0d said:
Tbh, I'm not sure why I didn't just do this to begin with. I was so focused on not adding this one-time check, even though it is done every time the mouse moves >.< Ever feel like tattooing a bullseye on your forhead to make it easier to slap at moments like these? ;)
They have those hats with the clapping hands on them. I always figured with a little modification, I could facepalm hands free.
@pspeed said:
They have those hats with the clapping hands on them. I always figured with a little modification, I could facepalm hands free.
You could make a bazillion dollars selling these on… erm… oh man… can’t remember the name of that site that features a new item every week (I think it is all they sell for the week)… it’s semi-focused at the IT crowd… I would buy one of these… erm… hands down >.<