blob: beb71de797319e5ec761309376c53c0c01c31c72 [file]
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to you under the Apache License,
Version 2.0 (the "License"); you may not use this file except in
compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<document id="spinners">
<properties>
<title>Spinners</title>
</properties>
<body>
<p>
<tt>Spinner</tt> is a component that provides a means of cycling through a list of
items. The items are defined by the spinner's model data, specified via the
"spinnerData" property. Spinners behave similarly to a single-select
<tt>ListView</tt> or a <tt>ListButton</tt>, allowing a user to select one of the items
in the list. However, unlike list views and list buttons, spinners only present a
single item at a time.
</p>
<p>
Note that spinners may be "circular". When a spinner's "circular" property is set to
<tt>true</tt>, the spinner's selection will wrap when it reaches the first or last
item in the list. In the following example, the first spinner is circular, and the
second is not:
</p>
<application class="org.apache.pivot.wtk.ScriptApplication"
width="160" height="30">
<libraries>
<library>core</library>
<library>wtk</library>
<library>wtk-terra</library>
<library>tutorials</library>
</libraries>
<startup-properties>
<src>/org/apache/pivot/tutorials/boundedrange/spinners.bxml</src>
</startup-properties>
</application>
<p>
Because spinner data is specified using an instance of the <tt>List</tt> interface,
spinners are quite flexible. The second spinner in the above example uses an instance
of <tt>NumericSpinnerData</tt> as its model. This class is a lightweight means of
representing a list of numeric value options: it doesn't actually store the values as
a list in memory - it simply calculates the appropriate value for a given index using
its lower and upper bounds and increment value.
</p>
<p>
The BXML for this example is shown below:
</p>
<source type="xml" location="org/apache/pivot/tutorials/boundedrange/spinners.bxml">
<![CDATA[
<Window title="Spinners" maximized="true"
xmlns:bxml="http://pivot.apache.org/bxml"
xmlns:content="org.apache.pivot.wtk.content"
xmlns="org.apache.pivot.wtk">
<BoxPane styles="{verticalAlignment:'center'}">
<Spinner spinnerData="['One', 'Two', 'Three', 'Four', 'Five']"
circular="true" preferredWidth="80" selectedIndex="0"/>
<Spinner preferredWidth="40" selectedIndex="0">
<spinnerData>
<content:NumericSpinnerData lowerBound="0" upperBound="9" increment="1"/>
</spinnerData>
</Spinner>
</BoxPane>
</Window>
]]>
</source>
<p>
Since this example contains no logic, there is no associated Java source.
</p>
</body>
</document>