Skip to content

Commit 1120ea7

Browse files
authored
update
1 parent 600179a commit 1120ea7

File tree

1 file changed

+52
-1
lines changed

1 file changed

+52
-1
lines changed

docs/development/barcodes.md

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,55 @@ Please note that this feature is only available when bootstrapping with the UI5
4343
:::
4444

4545
#### Device
46-
Most scanner devices have an integrated scanning function. In such cases, you can simply create an input field and ensure the focus is correctly set. The scanned data will populate the input field as if it were typed via a keyboard.
46+
Most scanner devices have an integrated scanning function. In such cases, you can simply create an input field and ensure the focus is correctly set. The scanned data will populate the input field as if it were typed via a keyboard.
47+
48+
Below is an example showing how to handle input focus and manage transitions between input fields after scanning and triggering ENTER:
49+
50+
```abap
51+
CLASS z2ui5_cl_sample_focus DEFINITION PUBLIC FINAL CREATE PUBLIC .
52+
53+
PUBLIC SECTION.
54+
INTERFACES z2ui5_if_app.
55+
DATA one TYPE string.
56+
DATA two TYPE string.
57+
DATA focus_id TYPE string.
58+
59+
ENDCLASS.
60+
61+
CLASS z2ui5_cl_sample_focus IMPLEMENTATION.
62+
METHOD z2ui5_if_app~main.
63+
64+
IF client->check_on_init( ).
65+
focus_id = 'id1'.
66+
67+
DATA(page) = z2ui5_cl_xml_view=>factory( )->page( ).
68+
page->simple_form(
69+
)->content( ns = 'form'
70+
)->label( 'One'
71+
)->input(
72+
id = 'id1'
73+
value = client->_bind_edit( one )
74+
submit = client->_event( 'one_enter' )
75+
)->label( 'Two'
76+
)->input(
77+
id = 'id2'
78+
value = client->_bind_edit( two )
79+
submit = client->_event( 'two_enter' ) ).
80+
81+
page->_z2ui5( )->focus( focusid = client->_bind( focus_id ) ).
82+
client->view_display( page->stringify( ) ).
83+
84+
ENDIF.
85+
86+
CASE client->get( )-event.
87+
WHEN 'one_enter'.
88+
focus_id = 'id2'.
89+
client->view_model_update( ).
90+
WHEN 'two_enter'.
91+
focus_id = 'id1'.
92+
client->view_model_update( ).
93+
ENDCASE.
94+
95+
ENDMETHOD.
96+
ENDCLASS.
97+
```

0 commit comments

Comments
 (0)