Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.97a is out! (02/02/24); New blog post: Simulator Enhancements (03/13/24)

Author Topic: Cannot scroll with a mouse (edge case)  (Read 561 times)

Jaghaimo

  • Admiral
  • *****
  • Posts: 661
    • View Profile
Cannot scroll with a mouse (edge case)
« on: October 02, 2021, 04:02:27 AM »

I've been building rather complicated UIs lately, and noticed an odd case where my mouse scrolling stops working. Unfortunately, I wasn't able to reproduce the steps using simple TooltipMakerAPI / CustomPanelAPI calls combination, so you will have to load my whole mod :(

Before we start, this may be very much user error and a feature-not-a-bug case. If so, do please tell me what I'm doing wrong.

Steps:
  • Load my mod (no deps needed) - here's the "build" for your perusal (along with source code if you need): https://github.com/jaghaimo/stelnet/releases/tag/1.3.0-bug
  • Start a new game and go to intel tab -> Market tag
  • Select View Market board, select market - something bigger that will give you a scroller (or have tiny screen:))

Now, scrolling does work when clicked, but not when using mouse scroll. Other, similar usages work fine (as seen with the other intel):
This one works: https://i.imgur.com/Mik4TKb.png
This one doesn't: https://i.imgur.com/VDeyJ3B.png
« Last Edit: October 02, 2021, 04:23:10 AM by Jaghaimo »
Logged

Jaghaimo

  • Admiral
  • *****
  • Posts: 661
    • View Profile
Re: Cannot scroll with a mouse (edge case)
« Reply #1 on: October 02, 2021, 08:31:22 AM »

I've managed to narrow it down to different sizes of first inner TooltipMakerAPI in which content of the tab, so all below the horizontal line, is put.

If the size is 1227,735 (autocalculated based on content) everything scrolls nicely. If it is 1235,755 (which I calculate myself based on screen dims) then mouse scroll does not work.

Commenting this line, makes the content suddenly mouse-scrollable: https://github.com/jaghaimo/stelnet/blob/market-refac/src/main/java/stelnet/storage/view/StorageTabViewFactory.java#L76

Internally, same methods and order of calls is done, just different numbers fed to `createUIElement`. ODD. Does it smell like a bug?

EDIT: I think I see it. The outer tooltip is smaller than custom panel that is put in it, which then has the inner tooltip inside that is larger than this custom panel. So the outer tooltip doesn't need a scroller, but the inner one does, yet as the panel stretches outside the outer tooltip it could be the cause of the failure (perhaps it simply doesn't propagate the scroll event)?

EDIT 2: Or perhaps, because the custom panel stretches outside "large intel" dimensions? :thonk:
« Last Edit: October 02, 2021, 09:58:53 AM by Jaghaimo »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Cannot scroll with a mouse (edge case)
« Reply #2 on: October 02, 2021, 10:07:11 AM »

Hmm - I just tried to reproduce this, and after making a new game and opening up the Markets tag in intel and selecting "Market Viewer", it tells me "There are no matching items to display".
Logged

Jaghaimo

  • Admiral
  • *****
  • Posts: 661
    • View Profile
Re: Cannot scroll with a mouse (edge case)
« Reply #3 on: October 02, 2021, 10:18:51 AM »

Did you select a market (bottom right button)?
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Cannot scroll with a mouse (edge case)
« Reply #4 on: October 02, 2021, 10:43:32 AM »

Ahh, that was it! Didn't realize that "select market" was a button and assumed they'd just be listed. Yep, I'm seeing the same scrolling issue; going to have a look...
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Cannot scroll with a mouse (edge case)
« Reply #5 on: October 02, 2021, 11:08:07 AM »

Fixed this up! The issue was with nesting scrollers - for processing mousewheel events, the outer scroller was checking "if content size >= scroller size" instead of ">" and in this case, when the content size and scroller size matched exactly, was eating the scroll events.

Edit: thank you for the detailed report and the stand-alone mod, btw. I really appreciate it - made it nice and easy to reproduce and fix.
Logged

Jaghaimo

  • Admiral
  • *****
  • Posts: 661
    • View Profile
Re: Cannot scroll with a mouse (edge case)
« Reply #6 on: October 02, 2021, 11:19:49 AM »

A win win then. On my end I simplified the code, and removed few setSize calls :)
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Cannot scroll with a mouse (edge case)
« Reply #7 on: October 02, 2021, 12:00:32 PM »

*thumbs up* :)
Logged