Samples / Controls / sap.ui.core
InvisibleMessage
The InvisibleMessage provides a way to programmaticaly expose dynamic content changes in a way that can be announced by screen readers.
- Class
z2ui5_cl_smpc_app_141- Repository
- abap2UI5/samples-controls
- Ports
sap.ui.core.sample.InvisibleMessage- UI5 libraries
- sap.m, sap.ui.core
- Lowest UI5 release
- 1.78
- In the browser
- Runs in the playground
- Controls it builds
- sap.m.Button, sap.m.FlexItemData, sap.m.HBox, sap.m.Page, sap.m.Text, sap.ui.core.mvc.View
The class
" @keywords invisiblemessage invisible message sap.ui.core a11y hbox button flexitemdata text
" @summary The InvisibleMessage provides a way to programmaticaly expose dynamic content changes in a way that can be announced by screen readers.
" @origin sap.ui.core.sample.InvisibleMessage - https://sdk.openui5.org/entity/sap.ui.core.InvisibleMessage/sample/sap.ui.core.sample.InvisibleMessage (status: reviewed - read against the original, not run)
CLASS z2ui5_cl_smpc_app_141 DEFINITION PUBLIC.
PUBLIC SECTION.
INTERFACES z2ui5_if_app.
DATA statustext TYPE string.
PROTECTED SECTION.
DATA client TYPE REF TO z2ui5_if_client.
METHODS view_display.
METHODS on_event.
PRIVATE SECTION.
ENDCLASS.
CLASS z2ui5_cl_smpc_app_141 IMPLEMENTATION.
METHOD z2ui5_if_app~main.
me->client = client.
IF client->check_on_init( ).
statustext = `There is no message sent to the invisible message service. Please, press a button.`.
view_display( ).
ELSEIF client->check_on_navigated( ).
view_display( ).
ELSEIF client->check_on_event( ).
on_event( ).
ENDIF.
ENDMETHOD.
METHOD view_display.
DATA(view) = z2ui5_cl_ui5_view_builder=>factory( ).
view->ele( n = `View` ns = `mvc`
)->a( n = `xmlns` v = `sap.m`
)->a( n = `xmlns:mvc` v = `sap.ui.core.mvc`
)->a( n = `xmlns:core` v = `sap.ui.core`
)->a( n = `height` v = `100%`
)->ele( `Page`
)->a( n = `showHeader` v = `false`
)->a( n = `class` v = `sapUiContentPadding`
)->ele( `content`
)->ele( `HBox`
)->ele( `Button`
)->a( n = `text` v = `Infromation`
)->a( n = `press` v = client->_event( val = `PRESS`
t_arg = VALUE #( ( `$event.oSource.getType()` )
( `$event.oSource.getText()` ) ) )
)->ele( `layoutData`
)->tag( `FlexItemData`
)->a( n = `growFactor` v = `1`
)->end(
)->end(
)->ele( `Button`
)->a( n = `type` v = `Accept`
)->a( n = `text` v = `Success`
)->a( n = `press` v = client->_event( val = `PRESS`
t_arg = VALUE #( ( `$event.oSource.getType()` )
( `$event.oSource.getText()` ) ) )
)->ele( `layoutData`
)->tag( `FlexItemData`
)->a( n = `growFactor` v = `1`
)->end(
)->end(
)->ele( `Button`
)->a( n = `type` v = `Reject`
)->a( n = `text` v = `Error`
)->a( n = `press` v = client->_event( val = `PRESS`
t_arg = VALUE #( ( `$event.oSource.getType()` )
( `$event.oSource.getText()` ) ) )
)->ele( `layoutData`
)->tag( `FlexItemData`
)->a( n = `growFactor` v = `1`
)->end(
)->end(
)->tag( `Button`
)->a( n = `type` v = `Emphasized`
)->a( n = `text` v = `Emphasized`
)->a( n = `press` v = client->_event( val = `PRESS`
t_arg = VALUE #( ( `$event.oSource.getType()` )
( `$event.oSource.getText()` ) ) )
)->end(
)->ele( `HBox`
)->tag( `Text`
)->a( n = `id` v = `statustext`
)->a( n = `text` v = client->_bind( statustext ) ).
client->view_display( view->stringify( ) ).
ENDMETHOD.
METHOD on_event.
IF client->get_event( ) = `PRESS`.
" original onPress: announces the pressed button's type+text to the
" InvisibleMessage a11y service and echoes it into the status Text. The
" pressed button's identity rides along as event args, the message is
" composed here exactly as the original concatenates it, and the
" announcement itself goes out through the INVISIBLE_MESSAGE global
" target - the singleton has no control id, so control_global is the
" only route to it (same wire as apps 289 and 435)
DATA(message) = |Button with type { client->get_event_arg( ) } | &&
|and text { client->get_event_arg( 2 ) } is pressed|.
client->follow_up_action( val = client->cs_event-control_global
t_arg = VALUE #( ( `INVISIBLE_MESSAGE` )
( `announce` )
( message )
( `Assertive` ) ) ).
statustext = |A new message with text: "{ message }" | &&
|was sent to the invisible messaging service.|.
ENDIF.
ENDMETHOD.
ENDCLASS.