I don’t know if there’s a way to change the behavior of the built-in confirmation dialog, but to achieve your desired result, you could create your own simple popup, and even parametrize it for the tag you’re changing.
If you script the yes and no buttons with a keyPressed action handler and use if(event.keyCode == event.VK_ENTER): to filter for the enter key when the button is selected, that should do the trick.
@JordanCClark Thank you so much! This solution worked perfectly for me and solved the issue I was struggling with. Really appreciate your help!
I need one more help from you with my code.
from javax.swing import JOptionPane, UIManager
UIManager.put("Button.defaultButtonFollowsFocus", True)
choice = JOptionPane.showConfirmDialog(
None,
"Do you really want to continue?",
"Title",
JOptionPane.OK_CANCEL_OPTION
)
UIManager.put("Button.defaultButtonFollowsFocus", False)
if choice == JOptionPane.OK_OPTION:
system.gui.messageBox("OK clicked")
elif choice == JOptionPane.CANCEL_OPTION:
system.gui.messageBox("Cancel clicked")
Whenever the popup opens, I don’t want the OK button to be automatically selected or focused; I want the focus to move to the buttons only when I press TAB.