Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9000815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:21:26+00:00 2026-06-16T00:21:26+00:00

Editable JavaFx ComboBoxes works well but the left-arrow key is interpreted as Shift-TAB. As

  • 0

Editable JavaFx ComboBoxes works well but the left-arrow key is interpreted as Shift-TAB.

enter image description here

As you can see the focus is set to the ComboBox and the insertion point is in the middle of its field. Pressing the left arrow key move the focus to the first control, the TextField on the left of the image when pressing right arrow key move the insertion one character right as expected like in any TextField.

How can I catch events to reproduce the behavior of a TextField in an editable ComboBox?

I’ve tried to catch key events via ComboBox.setOnKeyPressed() and event.consume() but without success.

Here is a minimal program to reproduce this unexpected behavior:

@Override
public void start( Stage stage ) {
   stage.setTitle( "Editable ComboBox and left-arrow key" );

   ComboBox<String> cmbBx = new ComboBox<>();
   cmbBx.getItems().addAll( "A", "B", "C", "D", "E" );
   cmbBx.setMinWidth( 150 );
   cmbBx.setEditable( true );
   cmbBx.setOnKeyPressed( new EventHandler<KeyEvent>(){
      @Override public void handle( KeyEvent event ) {
         System.err.println( event );
         event.consume(); }}); // Consuming left arrow key is inoperant

   GridPane grid = new GridPane();
   grid.setVgap( 4 );
   grid.setHgap( 4 );
   grid.setPadding( new Insets( 4, 4, 4, 4 ));

   grid.add( new Label( "TextField:" ), 0, 0 );
   grid.add( new TextField()          , 1, 0 );
   grid.add( new Label( "ComboBox:" ) , 2, 0 );
   grid.add( cmbBx                    , 3, 0 );

   stage.setScene( new Scene( grid ));
   stage.show();
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:21:26+00:00Added an answer on June 16, 2026 at 12:21 am

    The answer is around key bindings like shown in this SO post “key bindings in javafx”.

    This code catch the LEFT event:

      cmbBx.addEventFilter( KeyEvent.ANY, new EventHandler< KeyEvent >() {
         @Override public void handle(KeyEvent event ) {
            if( event.getCode() == KeyCode.LEFT ) {
               event.consume(); }}});
    

    And that’s all, but I’m surprised because the left arrow key move the insertion point as expected, only the undesired behavior is removed. Why?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a flex editable datagrid mx:DataGrid and when I press TAB key, it
I have a editable div: <div id=artikel contenteditable=true></div> It works nice, I can edit
I am testing JavaFX 2.1 and trying to get editable table views to behave
I store user editable articles in a database. Users can insert some simple widgets
I've made an editable list with elements that can be dragged around using jQuery
Is there an editable textarea in javascript/html that I can search the contents of,
I have a javafx editable ComboBox. The value property is updated only when i
I'm trying to put an html table in an editable JTextPane. So you can
What I know that theoretically you can force a jTable to be non-editable by
I need a non-editable field in a word form that can be read in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.