空格键在许多 UI 字段上都有默认操作:单击按钮字段、选择/取消选择复选框、在垂直字段管理器上滚动。
我的屏幕有一个超过 20 行的列表字段。当用户点击空格键时,我希望列表字段滚动。
例如,黑莓默认日历应用程序,当我们按空格键时,它会向下滚动。
和黑莓默认的短信一样,当我们按空格键时,它会向下滚动。
这是默认属性吗?或者我需要为空格键编写代码吗?
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?
发布评论
评论(1)
您必须创建一个自定义按键侦听器:
然后使用按键侦听器的实例作为参数调用
Mainscreen.addKeyListener
。从那里,您可以使用
Manager.setVerticalScroll
方法。如果您想增加它,您可以调用Manager.getVerticalScroll
然后添加一个固定值。如果您的屏幕中没有嵌套的VerticalFieldManager
,您可以尝试使用屏幕的默认设置,您可以通过调用Mainscreen.getMainManager
。更新:
对于列表字段,您可以调用
ListField.getSelectedIndex
和 < code>ListField.setSelectedIndex 来更改元素,但这不是平滑的滚动。但是,如果将列表字段放置在 VerticalFieldManager 中,则可以如上所述更改管理器滚动。You have to create a custom key listener:
Then call
Mainscreen.addKeyListener
with an instance of your key listener as parameter.From there you can change your manager (main manager or nested one) scroll with the
Manager.setVerticalScroll
method. If you want to increment it, you can retrieve the current scroll callingManager.getVerticalScroll
and then add a fixed value. In case you don't have a nestedVerticalFieldManager
in your screen, you can try with your screen's default, which you can obtain callingMainscreen.getMainManager
.UPDATE:
For List fields, you can call
ListField.getSelectedIndex
andListField.setSelectedIndex
to 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.