Discussion Locked

Disabling F4 key for comboboxes

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have the following problem. I have programmed a dialog where one of the buttons is registered to react to the F4 key being pressed. This works, no problem. Only if I am in a Combobox and press F4, the Combobox opens which is not desired. The F4 button DOES still get pressed too, but I would like to suppress the combobox opening its list.

Does anyone have any ideas? Just in case you are wondering how I registered the F4 key, here is how:

KeyStroke F4Key = KeyStroke.getKeyStroke( KeyEvent.VK_F4, 0 );
String F4actiontext = "F4_ACTION";
InputMap panel_im = getInputMap( JComponent.WHEN_IN_FOCUSED_WINDOW );
panel_im.put( F4Key, F4actiontext );
ActionMap panel_am = getActionMap();
panel_am.put( F4actiontext, new KeyActionListener(F4actiontext) );

2 replies

by gary_w

I have to suggest you use a different key than F4 for your button. It's not a good idea to override the standard windows functionality. Once a user learns F4 drops down the list, they should expect this action should work in all combo boxes. Use some other unused key instead.

Gary

by shepps

Of course, this option did occur to me. However I really wanted four F keys in a row and plenty of other keys also have standard functionality. F5 refreshes, F6 swaps panes etc. etc. At the end of the day, you end up having to contradict some standard somewhere. Also, the key combination alt-arrow down is good enough to pop up comboboxes.

Think about Microsoft products too. Word has F9 for refresh field, yet F5 is refresh in Internet Explorer.

This discussion is closed to new replies.