G4P making a text field focused in a secondary window
in
Contributed Library Questions
•
7 months ago
One last question...
I have a G4P GUI that uses a button on the main window to mute and unmute a Text-To-Speech routine.
There is a secondary window which holds the text field I type into.
The problem is that when I click on the mute button, the TTS gets muted, but focus is lost on the secondary window.
I tried setting focus in the following code but it still does not bring focus back to the text field.
The text field needs me to click within it to get focus back... is there a way to have it refocused without having to move the pointer back into the window???
When I open the secondary window for the first time it is already focused within the text field so I can start typing immediately...
the problem is when I go back to the primary window to mute...
TTS mute button:
- public void tts_click1(GButton source, GEvent event) { //_CODE_:tts:896734:
if (ttsOnOffFlag==0){ txf1.setFocus(true); ttsOnOffFlag=1; txf1.setFocus(true);
}else {
ttsOnOffFlag=0;
txf1.setFocus(true);
txf1.setFocus(true);
}
}
Secondary Window turned on by another button:
- public void type_click1(GButton source, GEvent event) { //_CODE_:type:205440:
calibPNL.setVisible(false);
remotePNL.setVisible(false);
typePNL.setVisible(true);
blankPNL.setVisible(false);
if (typeOnOffFlag==1){
window1.close();
typeOnOffFlag=0;
}else{typeOnOffFlag=1;
window1 = new GWindow(this, "Window title", 62, 708, 1858,60, true, JAVA2D);
window1.setActionOnClose(G4P.CLOSE_WINDOW);
window1.addDrawHandler(this, "win_draw2");
txf1 = new GTextField(window1.papplet, 5,5, 1848, 50, G4P.SCROLLBARS_NONE);
txf1.setFont(new Font("Dialog", Font.PLAIN, 40));
txf1.setFocus(true);
txf1.setOpaque(false);
txf1.addEventHandler(this, "txf1_change1");
}
}
1