mabe02 / lanterna

Java library for creating text-based GUIs
GNU Lesser General Public License v3.0
2.24k stars 243 forks source link

Lanterna 487 redux mouse move #493

Closed ginkoblongata closed 4 years ago

ginkoblongata commented 4 years ago

Keeps mouse & mouse drag delineated correctly. Mouse move will change selection in ListBox style widgets but not do the 'action' until mouse pressed, or keyboard actioning. Other widgets like Button, do not need to have it toggling focus, as the mouse passes throughout the ui screens. (maybe those should too?)

ginkoblongata commented 4 years ago

What happened:

Some context: I was using Konsole to develop, when I went to work on ScrollPanel, I realized that Konsole does not generate adequate mouse position actions. It seems to use about halfway prior and after the character boundary as pixels for the actual character, the result is that it's inadequate for precision clicking. So I moved over to XTerm, which has good proper bounds on the characters themselves as far as the columns for mouse actions. Then I see that when first starting the XTerm, it's generating mouse DRAGS until I click somewhere, rather than the mouse MOVES. I updated the mouse action pattern matcher to include state and it coerces these DRAGS to MOVES until the state is mouse DOWN, then during that mouse down state, it coerces MOVES to DRAGS as well although I did not encounter this case.

I am not sure the exact mechanism which causes the terminal to generate the DRAG initially, maybe race condition or something. Was testing with :

com.googlecode.lanterna.gui2.ThemeTest --mouse-move

ginkoblongata commented 4 years ago

I believe this pull request is done and ready for scrutiny and merging.

mabe02 commented 4 years ago

Looks good, thank you!