cancel
Showing results for 
Search instead for 
Did you mean: 

Global onEnter Event for a View

Former Member
0 Kudos

Hey,

Is it possible to create an "onEnter"-Event for a view so it triggered when the user is pressing enter, no matter which element or input field is selected?

I implemented an "onEnter"-Event but it's bound to an input field and so can only be triggered if this one is selected.

If someone has an answer it would be great if you could explain it for an WD beginner, because that's what I am right now ...

Accepted Solutions (0)

Answers (2)

Answers (2)

RicardoRomero_1
Active Contributor
0 Kudos

Hi,


May be you can try assigning the OnEnter action to all the input fields dinamically.

Something like this ( I am writing this quickly and I haven't test it, may be you need to change something)

You can put this code in your WDDOINIT or WDDOMODIFYVIEW checking the parameter FIRST_TIME.


DATA:

    lt_children    TYPE cl_wd_uielement=>tt_uielement,

    lo_view        TYPE REF TO cl_wdr_view,

    lo_element     TYPE REF TO cl_wd_uielement,

    lo_input_field TYPE REF TO cl_wd_input_field,

    lo_container   TYPE REF TO cl_wd_uielement_container.

* Read all the elements in your View

lo_view ?= wd_this->wd_get_api( ).

lo_container ?= lo_view->root_element.

lt_children = lo_container->get_children( ).


LOOP AT lt_children INTO lo_element.


* Input fields; "May be you can use here the class cl_abap_typedescr

   TRY.

     lo_input_field ?= lo_element.

     CATCH cx_sy_move_cast_error.

       CONTINUE.

   ENDTRY


 

   CALL METHOD lo_input_field->set_on_enter

     EXPORTING

       value  = 'MY_ONENTER_ACTION'.

ENDLOOP.

Regards,
Ricardo.

Former Member
0 Kudos

Thank you for this great effort by writing this code amazing.

We`re going to try it right away

Szczerbowski
Active Participant
0 Kudos

If it worked feel free to mark this question as answered.

Szczerbowski
Active Participant
0 Kudos

Not sure that is doable..

Maybe you could describe a bit more in detail why would you need such an event?

Former Member
0 Kudos

My colleauges got a WebDynpro which loads UI-Elements only when they are needed.

I added events in my WD by using "onEnter" attribute of the UI elements. But therefore the Inputfield with the "onEnter" event has to be selected.

Because the there elements are dynamically loaded they can't set the events in the "Layout" tab in the WebDynpro. So they need something like a "global" event that is triggered no matter what Input field is selected.

Sorry that I got no further information about this project right now.

Szczerbowski
Active Participant
0 Kudos

I didn't find a good solution with subscription and listeners, but you could try, depending on your access to those UI elements.

If those UI elements are part of your screen, but added dynamically, then i guess in wddomodify you can loop over and use the SET_ON_ENTER method (for example for cl_wd_input_field).

If those fields come from used components, then your colleagues would have to expose an interface event ON_ENTER you can subscribe to, and they should trigger it for their local ON_ENTER actions.