如何在flex中创建文本步进控件?
我需要 Flex 3 中的一个类似于 NumericStepper 的控件,但可以显示任意字符串。这个控制存在吗?如果没有,您对创建它有什么建议,或者您会推荐哪些参考资料?
为了方便起见,我将其称为 TextStepper。我希望这是一种紧凑的方式来显示用户可以通过单击向上/向下按钮循环浏览的字符串选择列表。紧凑意味着控件没有下拉或弹出方面:更改所选索引的唯一方法是单击向上/向下按钮(这会更新文本输入值)。值循环意味着我真的想将底层 dataProvider 视为循环缓冲区。因此,向上/向下单击以模方式修改 selectedIndex。
I need a control in Flex 3 that is like NumericStepper, but that can display arbitrary strings. Does this control exist? If not, what are your suggestions for creating it, or references you would recommend?
For convenience, I'm calling this a TextStepper. I want this as a compact way to display a list of string choices that a user can cycle through by clicking the up/down buttons. Compact means no drop-down or pop-up aspects of the control: the only way to change the selected index is to click the up/down button (which updates the text input value). Value cycling means that I really want to treat the underlying dataProvider as a circular buffer. So up/down clicks modify selectedIndex in modulo fashion.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这个想法是使用
valueFormatFunction
:StringStepper 的源代码:
The idea is to use
valueFormatFunction
:Source for StringStepper:
我通过将
TextInput
覆盖在NumericStepper
(绝对定位)上创建了其中一个(作为 MXML 组件),以便TextInput
覆盖了输入NumericStepper
的一部分。dataProvider 是一个字符串
ArrayCollection
,NumericStepper
的值用于访问ArrayCollection 中的索引。NumericStepper
的更改事件将TextInput
的文本更改为 dataProvider 索引 n 处的文本。我为组件提供了一个可编辑属性,它将TextInput
设置为可编辑,并将新字符串插入到当前索引处的 dataProvider 中。I created one of these (as an MXML comoponent) by overlaying a
TextInput
over aNumericStepper
(absolutely positioned) so that theTextInput
covered the input portion of theNumericStepper
.The dataProvider was an
ArrayCollection
of strings, and the value of theNumericStepper
was used to access an index in the ArrayCollection.The change event of the
NumericStepper
changed the text of theTextInput
to whatever was at index n of the dataProvider. I gave the component an editable property, which set theTextInput
to editable and inserted the new string into the dataProvider at the current index.