Bug - Fixed Focus cannot be set text fields in the topmost window that opens on start

MCroft

Developer
Staff member
I'm sure I've seen a report on this before, but my google-fu is failing me and I can't figure out the search terms to come up with it.

Here's the steps I'm taking (using vanilla r20476)
1:Add Modifier Maximizer to "Open as Window" column of Main Interface preference.
2: Exit KoLmafia
3: Restart KoLmafia
4: Attempt to click on "Max Price" or Maximize

Expected Result: Focus on the text field + available for text entry/editing
Actual Result: Focus/Text entry do not happen, as if it weren't clicked.
All other controls (checkboxes, radio buttons, buttons) work, just not text.

Workaround: selecting another window or switching to another app and back allows normal operation.

I'm not sure what's happening on gaining focus that's not happening on create, and I haven't seen any obvious suspects in my (admittedly brief) look for the problem.
 
Last edited:

fronobulax

Developer
Staff member
If KoLmafiaGUI.constructFrame( String ) was changed (or overloaded) to return the frame just created, the creation look could save the most recently created frame an request focus on it or maybe just unconditionally request focus.

Hmmm...
 

MCroft

Developer
Staff member
If KoLmafiaGUI.constructFrame( String ) was changed (or overloaded) to return the frame just created, the creation look could save the most recently created frame an request focus on it or maybe just unconditionally request focus.

Hmmm...

First pass through it on the initial go I had every frame that was constructed request focus, and it was sorta flashy, so I waited until the end. That said, it would keep me from having to retrieve and iterate the frames array if I could assign the frame to a variable inside the loop and let the last one stick...
 

MCroft

Developer
Staff member
no reason not to overload it. We can avoid duplicating code by having void constructFrame(String) call frame constructFrame(String frameName, Boolean askForFocus).

I don't even need a return frame with contstructFrame(frameName, askForFocus).
 
Last edited:

fronobulax

Developer
Staff member
A helper function that accepts a string (name) and returns a frame with that name might be an alternative provided we are comfortable with all available frames having unique names and the possibility of null as a return. Breaking those assumptions might break the existing code but making a utility brings that into focus.

I wondered if requesting focus on creation would "flash" so...
 

MCroft

Developer
Staff member
This is what mafia does when the when it calls constructFrame( String frameName )

Code:
try
{
	Class frameClass = Class.forName( "net.sourceforge.kolmafia.swingui." + frameName );
	KoLmafiaGUI.constructFrame( frameClass );
}
catch ( ClassNotFoundException e )
{
	// [...]
}

Not advocating that, necessarily. But that could use your helper method.
 

fronobulax

Developer
Staff member
Well after all that discussion, I can't really convince myself that any of my ideas are better. I'll run with your patch, and submit tomorrow.
 
Top