Feature improve focus handling in tabbed chat

capitol

New member
Hi

I have now done some real development instead of just cosmetic changes to the code

Here is a patch that improves the way that focus is handled on the tabbed chat, it moves focus to the input box every time that the window gains focus.

This makes it possible to tab to the chat and start typing directly, even if you somehow managed to move away focus from the input field when you tabbed away (something that I manage to do way to frequently).

I have also added a unit test for the StateListener, I noticed that there wasn't any unit tests to begin with, so I took the liberty to add some infrastructure in the build file for running them (submitted as it's own feature).

The reason i opted to place the ChatWindowStateListener as a public class instead of as an internal private one was to be able to easily write tests for it, the style otherwise seems to be to place such classes as private internal ones, but that makes them hard to test.

the patch: http://frikod.se/~capitol/chatFocus.patch

and the commit on github: https://github.com/alexanderkjall/kolmafia/commit/280e030239ebc86dbe7095b3d07b62af5b4c4fac

best regards
Alexander Kjäll
 

Theraze

Active member
So... this doesn't actually involve the StateListener unit test anymore? The message above still contains that info... :)
 

capitol

New member
Here is an improved patch that will apply with patch -p1 : http://frikod.se/~capitol/0003-improved-the-way-that-the-tabbed-chat-recieves-focus.patch

The patch contains the unit test, as the test of the functionality belongs together with the implementation of the functionality and should be reviewed together (in my opinion). But since the test is totally contained in it's own directory it would be easy to only add the other changes in the patch to the repo if one wants. The unit test is also pretty simpleminded, as I don't have that much experience with unit testing swing components.
 

capitol

New member
Here is another patch-set for improving the chat:

http://frikod.se/~capitol/0035-got-the-chat-history-working-again-basic-functionall.patch
http://frikod.se/~capitol/0036-guard-against-an-ArrayIndexOutOfBoundsException-that.patch
http://frikod.se/~capitol/0037-now-the-current-chatline-is-kept-when-you-press-up-a.patch

When you are in chat you can now browse your old history by pressing up and down. Most of the code was already in place but it was a bit broken. I have restructured the code base a bit in order to manage to understand it better, and also written some unit tests so that the functionality doesn't break again without noticing :)

There is one part of the patch that I would like feedback on, in ThreadedListener.java i removed the check for if the keyCode was VK_ENTER, as that messed up the ability to have events trigger on any other key, did that code serve any important porpoise?

Link to commit on github:
https://github.com/alexanderkjall/kolmafia/commit/7066cf059c0ddb183d8c95be0ebcdd33cd1b2c16
https://github.com/alexanderkjall/kolmafia/commit/43fc774e7c58c84e0223c21a627e23ae8d93ebb6
https://github.com/alexanderkjall/kolmafia/commit/ef4f98dafec234a19c57db28310f585e33810d5d
 
Last edited:

capitol

New member
And here is what i think is the last patch in this series of improvements:

http://frikod.se/~capitol/0001-added-ctrl-number-as-a-shortcut-for-switching-tabs-i.patch

It's also a usability patch, and it adds crtl+<number> as shortcuts to the tabs, so that you can more easily change tabs when you are chatting with more than one person (or one person and your clan).

This one took a long time to write, mainly due to that i had to understand how keyboard events was handled, and do some digging around, I also had some vacation in the middle :).

link to github commit: https://github.com/alexanderkjall/kolmafia/commit/ba218cd27de2f788b2cfd72a560612776ed17a5c
 

Bale

Minion
It's also a usability patch, and it adds crtl+<number> as shortcuts to the tabs, so that you can more easily change tabs when you are chatting with more than one person (or one person and your clan).

It would help me if ctrl+tab moved to the next tab in sequence. I use ctrl+tab by reflex and it sometimes troubles me that it doesn't work in KoLmafia.
 

Catch-22

Active member
It would help me if ctrl+tab moved to the next tab in sequence. I use ctrl+tab by reflex and it sometimes troubles me that it doesn't work in KoLmafia.

I use ctrl+tab in a bunch of situations too. I would appreciate this, if I actually used chat.
 

capitol

New member
Thats a good suggestion :) I'll add in ctrl-tab as forward one tab, and ctrl-shift-tab as backwards one tab.
 

Catch-22

Active member
Thats a good suggestion :) I'll add in ctrl-tab as forward one tab, and ctrl-shift-tab as backwards one tab.

I'm sure you are aware of this but just in case, ctrl+tab when at the last tab would normally take you back to the first tab. Conversely, ctrl+shift+tab takes you to the last tab when on the first tab.
 

Bale

Minion
That's good to mention — regardless of how obvious it may be — just to be sure that it isn't forgotten.

Incidentally, I would use this on the main mafia window as well, not just chat. Please be sure it works there!
 

Theraze

Active member
Ctrl-Tab and Ctrl-Shift-Tab works fine for me in mafia and has... for as long as I've tried to use it. Might be a function of the OS though... Win7 64-bit here.
 

capitol

New member
Here is the two patches for making ctrl+tab work in chat:

http://frikod.se/~capitol/0039-some-class-layout-restructuring-in-order-to-follow-t.patch
http://frikod.se/~capitol/0040-making-crtl-tab-work-for-switching-tab.patch

and github links:
https://github.com/alexanderkjall/kolmafia/commit/1b90470014e5277c8ab04a9676b7c3b24cba72f9
https://github.com/alexanderkjall/kolmafia/commit/c7c28f94546540dfb1788db1b87bd14e991ec424

I have not made any changes to how the main window handles ctrl+tab events, as that's a somewhat different beast, I'll gladly look into it later, but i rather finish this project first :)
 
Top