SegmentedUI Events
The SegmentedUI widget has the following events associated with it:
doLayout Event
This event is invoked for every widget when the widget position and dimensions are computed.
Syntax
Read/Write
Read + Write
Remarks
This event is invoked for all the widgets placed inside flex containers. This event is invoked in the order in which the widgets are added to the widget hierarchy and expect the frame property of the widget is calculated and available for use within this event.
This event is used to set the layout properties of child widgets in the relation to self and peer widgets whose layout is not yet performed.
When doLayout event is called in a Segment, the platform will add the context parameter.
The number of times this event invoked may vary per platform. It is not recommended to write business logic assuming that this function is invoked only once when there is a change in positional or dimensional properties. This event will not trigger when transformations are applied though widget is moved or scaled or rotated from its original location.
Example
Platform Availability
- iOS
- Android
- Windows
- SPA
onDidFinishDataLoading Event
This event is triggered when data is finished loading in the segmentedUI using the setData method. It is generated by all view types of SegmentUI.
Syntax
Read/Write
Read + Write
Example
Platform Availability
This event is available on iPhone and iPad only.
onDragCompleted Event
The event is invoked when the drag and drop of a row in the Segment is complete.
Syntax
Parameters
this
Optional. SegmentUI reference
dragstartcontext
Optional. A table that contains row and section information when dragging of a row is started.
dragendcontext
Optional. A table that contains row and section information when dragging of a row is ended.
Read/Write
Read + Write
Remarks
You can call the onDragCompleted event when the enableReordering property is true to allow the app users to drag and drop a row within a segment.
Example
Platform Availability
- Available in the IDE
- Android
- iOS
onEditing Event
This event is triggered when a user indicates his desire to edit the row (delete or insert). This event is only triggered if the eidtStyle is set to SEGUI_EDITING_STYLE_ICON or SEGUI_EDITING_STYLE_SWIPE.
Syntax
Parameters
seguiWidget
Optional. Reference to the SegmentedUI widget that raised the event.
editmode
Optional. Specifies the editing mode either insert or delete. Following are the available options:
- SEGUI_EDIT_MODE_INSERT
- SEGUI_EDIT_MODE_DELETE
Note: To set the value through code, prefix the option with constants. such as _**constants.
sectionIndex
Optional. Specifies the index of the section to which the row belongs to.
rowIndex
Optional. Specifies the index of the row that has been clicked.
Example
Platform Availability
This event is available on iPhone and iPad only.
onRowClick Event
This event is triggered when the user click any row of the SegmentedUI.
Syntax
Parameters
seguiWidget
Optional. Reference to the SegmentedUI widget that raised the event.
sectionIndex
Optional. Specifies the index of the section to which the row belongs to.
rowIndex
Optional. Specifies the index of row that has been clicked.
selectedState
Optional. Specifies the selected state.
Note: selectedState is mandatory only when the selectionBehavior is set to SEGUI_SINGLE_SELECT_BEHAVIOR or SEGUI_MULTI_SELECT_BEHAVIOR. When the selectionBehavior is set to SEGUI_DEFAULT_BEHAVIOR, then this parameter is optional.
Read/Write
Read + Write
Remarks
This event is not raised if the clickable property in the metainfo is set to false.
In the Android platform, when a gesture or touch events are placed inside the flex template for the Segment widget, because of the propagation of events to the below container, the flex template may not receive onRowClick event.
Example
Platform Availability
Available on all platforms.
onRowDisplay Event
This event handler is used to overwrite the rows that are affected because of an operation on rows.
Syntax
Read/Write
Read + Write
Parameters
widget
Optional. The ID of the widget.
state
Optional. The state of the widget. Can be voltmx.segment.ADD, voltmx.segment.UPDATE, or voltmx.segment.VISIBLE.
currentRowContext
Optional. The sectionIndex and rowIndex of the element on which the animateRow api is called.
startRowContext
The sectionIndex and rowIndex of the first visible row.
endRowContext
Optional. The sectionIndex and rowIndex of the last visible row.
Return Values
None.
Remarks
This event overwrites the animations of rows that are being affected by operations on rows. For example, when the addRowAt is called with animation, this callback would be invoked when the animation on the row is about to start, so that other animations can be applied to the remaining rows.
Your callback function for this event should only call animateRows. It should call the animation on the individual row elements. For example, if a new element is being added and if the application needs to move the elements which are being displaced with an animation, then the application should be calling animationRows for the displaced elements but not for the widget which is being added/removed or updated.
This callback function is only invoked if the state of the segmentedUI widget changes in the visible region. It is not called on rows that are invisible.
Example
Platform Availability
Available on Android, iOS, SPA, and DesktopWeb.
onScrollStart Event
Indicates that scroll container started scrolling.
Syntax
Parameters
source
Specify the widget on which scrolling started.
Read/Write
Read + Write
Remarks
The onScrollStart event is called asynchronously. The event is triggered only when scrolling is started. When touch does not result to a scroll, this event is not raised.
Example
Platform Availability
- iOS
- Android
- Windows
- SPA
onScrollTouchReleased Event
Indicates that user scrolling touch on the display is released. This callback is called asynchronously.
Syntax
Parameters
source
Specify the segment on which scrolling touch is released.
Read/Write
Read + Write
Example
Platform Availability
- iOS
- Android
onScrolling Event
Indicates that segment scrolling is in progress. This callback is called asynchronously.
Syntax
Parameters
source
Specify the segment on which scrolling is in progress.
Read/Write
Read + Write
Example
Platform Availability
- iOS
- Android
- Windows
- SPA
onScrollEnd Event
Indicates that segment scrolling has come to an end.
Syntax
Parameters
source
Specify the segment on which scrolling is coming to an end.
Read/Write
Read + Write
Remarks
The onScrollEnd callback is called asynchronously. This event is called only when the scrolling reached end of the scroll.
When multiple scrolls performed on the Segment widget, the onScrollTouchReleased is triggered whenever touch is released, but the onScrollEnd event is triggered only when the entire scrolling is ended. So when the user keeps on flinging on the display, the onScrollTouccReleased callback is triggered multiple times and onScrollEnd is triggered only once.
Example
Platform Availability
- iOS
- Android
- Windows
- SPA except for Desktop
onScrollWidgetPosition Event
This event callback is invoked by the platform when the widget location position gets changed on scrolling. The onScrollWidgetPosition event returns the positional coordinates of the widget’s location with respect to the screen (screenX and screenY) and the parent container (frameX and frameY). This event is invoked asynchronously, and is not available for FlexForm widget.
Syntax
Read/Write
Read + Write
Example
Platform Availability
- Not Accessible from IDE
- Android, iOS, SPA, and Windows
onSwipe Event
This event is triggered when you swipe a row in a segment.
Syntax
Parameters
seguiWidget
Optional. Reference to the SegmentedUI widget that raised the event.
sectionIndex
Optional. Specifies the index of the section where the current focused row belongs to. The value is -1 in case if there are no sections.
rowIndex
Optional. Specifies the index of the current focused row of the section.
selectionState
Optional. Specifies the selected state of the current focused rows checked or unchecked. It is available when selectionBehavior is set as SEGUI_SINGLE_SELECT_BEHAVIOR or SEGUI_MULTI_SELECT_BEHAVIOR mode. It is applicable to the following viewTypes:
- SEGUI_VIEW_TYPE_PAGEVIEW
- SEGUI_VIEW_TYPE_COVERFLOW (iOS and Android)
- SEGUI_VIEW_TYPE_STACK (iOS)
- SEGUI_VIEW_TYPE_LINEAR (iOS)
- SEGUI_VIEW_TYPE_ROTATORY (iOS)
- SEGUI_VIEW_TYPE_INVERTED_ROTARY (iOS)
- SEGUI_VIEW_TYPE_CYLINDER (iOS)
- SEGUI_VIEW_TYPE_INVERTED_CYLINDER (iOS)
Read/Write
Read + Write
Remarks
This event is available only when the viewType is set to page view.
Example
Platform Availability
Available on all platforms
preOnclickJS Event
This event allows the developer to execute custom javascript function before the onClick callback of the widget is invoked.
Syntax
Read/Write
Read + Write
Remarks
This is applicable only for Mobile Web channel. The function must exist in a javascript file under project>module>js folder.
In for the events preOnclickJS and postOnclickJS you will not be able to access application model or APIs, as these functions are executed in browser whereas the remaining JS modules are executed in server. For these events you can access browser objects ( window, document etc..) to change UI or perform some validation before server event. If the event preOnclickJS returns true, only then the request is sent to server for subsequent action.
You have to specify the modules to be loaded in browser using import JS tab, only then these files get included in.html script tag otherwise you will not be able to access the objects defined in those modules.
Example
Platform Availability
- Available in the IDE
- Available on Server side Mobile Web (BJS and Advanced) platform only
postOnclickJS Event
This event allows the developer to execute custom javascript function after the onClick callback of the widget is invoked.
Syntax
Read/Write
Read + Write
Remarks
This is applicable only for Mobile Web channel. The function must exist in a javascript file under project>module>js folder.
Example
Platform Availability
- Available in the IDE
- Available on Server side Mobile Web (Advanced) platform only
onReachingBeginning Event
onReachingBeginning gets called when scrolling reaches the beginning of the SegmentedUI widget.
Syntax
Parameters
seguiWidget
Optional. Handle to the widget reference.
Read/Write
Read + Write
Remarks
Following are the requirements and limitations to use this event on iOS and Android/Android Tablet platforms:
- This event is invoked only when it is placed directly inside a ScrollBox or in a Form
- Segment viewType must be set as SEGUI_VIEW_TYPE_TABLEVIEW
- The property screenLevelWidget must be set to true.
If segment is inside any other container widget like HBox/VBox then onPull, onPush, onReachingBegining and onReachingEnd events, cross platform behavior is undefined and these events might not be called.
On Android platform, if the rows height/number of rows is less than the screen display height, then onReaching preserve”>var var onPush event callbacks won’t get invoked.
Example
Platform Availability
Available in the IDE
Available on all platforms
Desktop Web support is added in V8 SP2
onReachingEnd Event
onReachingEnd gets called when scrolling reaches the end of the SegmentedUI widget.
Syntax
Parameters
seguiWidget
Optional. Handle to the widget reference.
Read/Write
Read + Write
Remarks
Following are the requirements and limitations to use this event on iOS and Android/Android Tablet platforms:
- This event is invoked only when it is placed directly inside a ScrollBox or in a Form
- Segment viewType must be set as SEGUI_VIEW_TYPE_TABLEVIEW
- The property screenLevelWidget must be set to true.
If segment is inside any other container widget like HBox/VBox then onPull, onPush, onReachingBegining and onReachingEnd events, cross platform behavior is undefined and these events might not be called.
On Android platform, if the rows height/number of rows is less than the screen display height, then onReaching preserve”>var var onPush event callbacks won’t get invoked.
Example
Platform Availability
Available in the IDE
Available on all platforms
Desktop Web support is added in V8 SP2
onPull Event
An event callback that is invoked by the platform when scrolling the SegmentedUI widget.
onPull gets called when SegmentedUI is pulled from top.
Syntax
Parameters
seguiWidget
Optional. Handle to the widget reference.
Read/Write
Read + Write
Remarks
Note: The onPull and onPush events are not supported on Windows 10 Tablet.
Parameters
Following are the requirements and limitations to use this event on iOS and Android/Android Tablet platforms:
- This event is invoked only when it is placed directly inside a ScrollBox or in a Form
- Segment viewType must be set as SEGUI_VIEW_TYPE_TABLEVIEW
- The property screenLevelWidget must be set to true.
If segment is inside any other container widget like HBox/VBox then onPull, onPush, onReachingBegining and onReachingEnd events, cross platform behavior is undefined and these events might not be called.
On Android platform, if the rows height/number of rows is less than the screen display height, then onReaching preserve”>var var onPush event callbacks won’t get invoked.
Example
Platform Availability
Available in the IDE
Available on all platforms
onPush Event
An event callback that is invoked by the platform when scrolling the SegmentedUI widget.
onPush gets called when SegmentedUI is pushed from bottom.
Syntax
Parameters
seguiWidget
Optional. Handle to the widget reference.
Read/Write
Read + Write
Remarks
Note: The onPull and onPush events are not supported on Windows 10 Tablet.
Following are the requirements and limitations to use this event on iOS and Android/Android Tablet platforms:
- This event is invoked only when it is placed directly inside a ScrollBox or in a Form
- Segment viewType must be set as SEGUI_VIEW_TYPE_TABLEVIEW
- The property screenLevelWidget must be set to true.
If segment is inside any other container widget like HBox/VBox then onPull, onPush, onReachingBegining and onReachingEnd events, cross platform behavior is undefined and these events might not be called.
On Android platform, if the rows height/number of rows is less than the screen display height, then onReaching preserve”>var var onPush event callbacks won’t get invoked.
Example
Platform Availability
Available in the IDE
Available on all platforms