CLASS lcl_events DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
on_close FOR EVENT close OF cl_gui_dialogbox_container
IMPORTING sender.
CLASS-METHODS:
on_select FOR EVENT selected OF cl_gui_combobox
IMPORTING
key
sender.
CLASS-METHODS:
on_submit FOR EVENT submit OF cl_gui_input_field
IMPORTING
input
sender.
CLASS-METHODS:
on_auto_submit FOR EVENT auto_submit OF cl_gui_input_field
IMPORTING
input
sender.
ENDCLASS.
CLASS lcl_events IMPLEMENTATION.
METHOD on_close.
IF sender IS NOT INITIAL.
sender->free( ).
ENDIF.
ENDMETHOD.
METHOD on_select.
MESSAGE key && ' -> ' && sender->get_selected_item( ) TYPE 'S'.
cl_gui_cfw=>flush( ).
ENDMETHOD.
METHOD on_submit.
MESSAGE 'Submit:' && input && ' -> ' && sender->get_text( ) TYPE 'S'.
cl_gui_cfw=>flush( ).
ENDMETHOD.
METHOD on_auto_submit.
MESSAGE 'Auto-Submit:' && input && ' -> ' && sender->get_text( ) TYPE 'S'.
cl_gui_cfw=>flush( ).
ENDMETHOD.
ENDCLASS.
SELECTION-SCREEN: PUSHBUTTON 2(20) btn1 USER-COMMAND cmd_show.
AT SELECTION-SCREEN.
* wenn Button-Kommando 'CMD_SHOW'
IF sy-ucomm = 'CMD_SHOW'.
* Container
DATA(o_cnt) = NEW cl_gui_dialogbox_container( no_autodef_progid_dynnr = abap_true
caption = 'Werte'
top = 5
left = 5
width = 640
height = 240 ).
SET HANDLER lcl_events=>on_close FOR o_cnt.
* Input
DATA(o_input) = NEW cl_gui_input_field( parent = o_cnt
label_text = 'InputLabel'
label_width = 10
input_prompt_text = 'Text'
activate_find_button = abap_false
activate_auto_submit = abap_true ).
o_input->set_top( 30 ).
o_input->set_text( '<default>' ).
SET HANDLER lcl_events=>on_submit FOR o_input.
SET HANDLER lcl_events=>on_auto_submit FOR o_input.
* Combobox
DATA(o_combo) = NEW cl_gui_combobox( parent = o_cnt
label_text = 'ComboLabel'
label_width = 10 ).
o_combo->set_items( VALUE vrm_values( ( key = 'A' text = 'Wert1' )
( key = 'B' text = 'Wert2' )
( key = 'C' text = 'Wert3' ) ) ).
o_combo->set_selected_item( 'A' ).
o_combo->activate_selection_event( ).
o_combo->set_top( 10 ).
SET HANDLER lcl_events=>on_select FOR o_combo.
ENDIF.