|
| 1 | +# Troubleshooting |
| 2 | + |
| 3 | +#### Hide Soft Keyboard |
| 4 | + |
| 5 | +For UI5 input fields, the soft keyboard is automatically shown when focusing an input field. In some use cases, e.g. in the context of warehouses with small devices, this is not always wanted. To change this behavior, we have to adjust the HTML input element and switch the input type to `none`. The following snippet demonstrates how to activate/deactivate the soft keyboard: |
| 6 | + |
| 7 | +```abap |
| 8 | +
|
| 9 | + METHOD z2ui5_if_app~main. |
| 10 | +
|
| 11 | + IF client->check_on_init( ). |
| 12 | + |
| 13 | + DATA(view) = z2ui5_cl_xml_view=>factory( ). |
| 14 | + view->_generic( name = `script` |
| 15 | + ns = `html` )->_cc_plain_xml( `z2ui5.afterBE = (id , mode) => { ` && |
| 16 | + `debugger;` && |
| 17 | + `var input = z2ui5.oView.byId(id).getDomRef();` && |
| 18 | + `input = input.childNodes[0].childNodes[0];` && |
| 19 | + `input.setAttribute("inputmode" , mode);` && |
| 20 | + ` alert("inputmode changed to" + mode); }` ). |
| 21 | +
|
| 22 | + DATA(page) = view->shell( |
| 23 | + )->page( title = 'abap2UI5 - Softkeyboard on/off' |
| 24 | + navbuttonpress = client->_event( 'BACK' ) |
| 25 | + shownavbutton = client->check_app_prev_stack( ) |
| 26 | + )->_z2ui5( )->focus( focusid = `ZINPUT` |
| 27 | + )->simple_form( editable = abap_true |
| 28 | + )->content( 'form' |
| 29 | + )->title( 'Keyboard on/off' |
| 30 | + )->label( 'Input' |
| 31 | + )->input( id = `ZINPUT` |
| 32 | + value = client->_bind_edit( input ) |
| 33 | + showvaluehelp = abap_true |
| 34 | + valuehelprequest = client->_event( 'CALL_KEYBOARD' ) |
| 35 | + valuehelpiconsrc = 'sap-icon://keyboard-and-mouse' ). |
| 36 | +
|
| 37 | + client->view_display( page->stringify( ) ). |
| 38 | +
|
| 39 | + ENDIF. |
| 40 | +
|
| 41 | +
|
| 42 | + CASE client->get( )-event. |
| 43 | + WHEN 'CALL_KEYBOARD'. |
| 44 | + client->follow_up_action( `z2ui5.afterBE("ZINPUT", "none");` ). |
| 45 | + WHEN 'BACK'. |
| 46 | + client->nav_app_leave( ). |
| 47 | + ENDCASE. |
| 48 | +
|
| 49 | + ENDMETHOD. |
| 50 | +``` |
0 commit comments