• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Why is a single SPACE key press multiplied by the number of characters typed in a JavaFX ComboBox?  RSS feed

 
Ranch Hand
Posts: 54
2
Eclipse IDE IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do I keep the following KeyEvent Filter from adding multiple "SPACE" characters vs just a single character?

I'm aware that ControlsFX AutoComplete will allow for SPACE in an editable JavaFX ComboBox, but it does not for an un-editable ComboBoxes -- at least that I have found so far. The AutoComplete I'm using works with both an editable and un-editable ComboBox, however, code below will multiply a single "SPACE" bar key press times the number of characters typed - regardless of backing them out or not. For example, if you were to type "s" then space, this code will add a single space character after "s" (i.e. "s "). If you were to type "sat", a single "SPACE" will be added 3 times. And if you backspace and type pen, it will add 6 spaces for a single spacebar key press (e.g. sat + pen).

I feel I'm on the right path but may be using the wrong key event handler per se and maybe on the wrong object (e.g. ComboBox, Skin, etc)... not sure exactly.



Adds3_thenAdds4.JPG
[Thumbnail for Adds3_thenAdds4.JPG]
Adds 3 spaces after IVE and 4 spaces after T for a single space key press each
 
Scott Vallery
Ranch Hand
Posts: 54
2
Eclipse IDE IntelliJ IDE Java
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was able to resolve this issue. The addEventFilter for the ComboBoxListViewSkin should be implemented within the constructor and I had it within the onKeyPressed event.



AllowingSpaceInComboBox.JPG
[Thumbnail for AllowingSpaceInComboBox.JPG]
Space allowed
 
today's feeble attempt to support the empire
ScroogeXHTML - small and flexible RTF to HTML converter library
https://coderanch.com/t/710903/ScroogeXHTML-RTF-HTML-XHTML-converter
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!