The spacebar has a default action on many UI fields: click for buttonfield, select/unselect for checkbox, scrolling on a verticalfieldmanager.
My screen has a listfield with more than 20 rows. When the user hits the spacebar, I want the listfield to scroll.
For example, BlackBerry default calendar app, when we hit spacebar, it will scroll down.
and BlackBerry default text Messages, when we hit spacebar, it will scroll down.
is this a default property? or do I need to write code for spacebar key?
You have to create a custom key listener:
Then call
Mainscreen.addKeyListenerwith an instance of your key listener as parameter.From there you can change your manager (main manager or nested one) scroll with the
Manager.setVerticalScrollmethod. If you want to increment it, you can retrieve the current scroll callingManager.getVerticalScrolland then add a fixed value. In case you don’t have a nestedVerticalFieldManagerin your screen, you can try with your screen’s default, which you can obtain callingMainscreen.getMainManager.UPDATE:
For List fields, you can call
ListField.getSelectedIndexandListField.setSelectedIndexto change elements, but this is not an smooth scrolling. But if you placed the list field inside a VerticalFieldManager, you can change the manager scroll as described above.