ImageSelect - relu91/nifty-gui GitHub Wiki
The ImageSelect control allows the selection of a single image out of a list of images. The image can be selected using the left/right arrows the control provides. It is required that the images have the same size. Changing the selection will publish an Event on the EventBus. The control can be created dynamically from Java using the ImageSelectBuilder as well as from XML using the Standard <control></control> Tag.
The following parameters are supported by the ImageSelect control.
Name | Datatype | Default | Description |
imageWidth | SizeValue | "0px" | The width of the images that this ImageSelect control should display. This attribute is mandatory! |
imageHeight | SizeValue | "0px" | The height of the images that this ImageSelect control should display. This attribute is mandatory! |
imageList | comma separated list of image filenames | "" | This attribute contains a list of comma separated filenames which defines all the images that this image select control displays. |
The ImageSelect supports EventBus notification for any change of the selected image. When the selected image changes a ImageSelectSelectionChangedEvent is published using the id of the ImageSelect as the Topic for the Event.
ImageSelectSelectionChangedEvent
// Using the builder pattern
control(new ImageSelectBuilder("someImageSelect") {{
imageWidth("100px"); // please note that imageWidth and imageHeight are mandatory!
imageHeight("100px");
imageList("images/1.png,images/2.png,images/3.png");
}});
<!-- example imageSelect (right out of the multiplayer example which is part of the nifty-examples project) -->
<control id="#imageSelect" name="imageSelect" width="126px" imageWidth="80px" imageHeight="80px" imageList="multiplayer/avatar1.png,multiplayer/avatar2.png,multiplayer/avatar3.png,multiplayer/avatar4.png" />