Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

class cl_gui_textedit event handling

Former Member
0 Likes
2,082

CL_GUI_TEXTEDIT provides events like DBLCLICK,F1,F4.But is it possible to add my own events?if yes how?

CL_GUI_TEXTEDIT provides events like DBLCLICK,F1,F4.But is it possible to add my own events?if yes how?

11 REPLIES 11
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,808

I don't think so, first you would have to "hack" the a standard SAP class, which is not recommended, plus, that class interacts with objects on the frontend. If you just add an event to the class, that probably is not going to solve your problem. The frontend would have to be able to trigger the event.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
1,808

I agree with Rich that you would have to change the SAP code.

Some alternatives:

Drag and Drop is supported by the editor so you can write your own code to respond.

Add your own buttons to the control or the GUI status.

Context menus are supported and you add your own code behind the users selection.

Read only

Former Member
0 Likes
1,808

Hi Mainak Biswas,

Yes it is possible. Create a class inheriting your super class CL_GUI_TEXTEDIT. Now you can add your own events and trigger them along with already existing events like F4, double-click. Here you do not have to change the standard SAP class.

Regards,

Vara

Read only

0 Likes
1,808

can you tell me how can i register my own event.

Read only

0 Likes
1,808

HI Mainak Biswas...

You can set handler for your Events. This can be achieved using <b>SET HANDLER <hi> for <Obj>/[for all instances]</b>Here <hi> is your method. if you are setting an instance method then your method would be like this

<b><obj>-><method name></b>. <b>"FOR"</b> will be added if you are setting handler for specific instance. If you want your handler for all the instance then use

<b>"for all instances"</b>

If you want to set handler for a static event then "for" is not required.

For further reference click the link below...

http://help.sap.com/saphelp_47x200/helpdata/en/71/a8a77955bc11d194aa0000e8353423/content.htm

Regards,

Vara

Read only

0 Likes
1,808

Hello Mainak,

Is this an actual requirement that you have? Or are you just trying to play-around and see if it can be made possible?

In anycase, I don't think it is so simple as Vamsi seems to have made you believe. <i>It is almost never recommended to add your own events</i>. The common practice is to handle the already existing events in a customized way.

Regards,

Anand Mandalika.

Read only

0 Likes
1,808

Here is a sample program. This illistrates how the eventing works internal to the class. I am still confused about how you will fire this event from the frontend. You can fire from a "standard frontend event". But don't think that you can have a "custom frontend event"


** Create screen 100 with a custom container "CONTAINER".

report zrich_0001 .

*---------------------------------------------------------------------*
*       CLASS lcl_text_edit DEFINITION
*---------------------------------------------------------------------*
class lcl_text_edit definition inheriting from cl_gui_textedit.

  public section.

    data: textlines type table of tline-tdline,
          wa_text type tline-tdline.

    events: customevent.

    methods: constructor importing
               im_parent type ref to cl_gui_container,

             customeventhandle
                     for event dblclick of lcl_text_edit.

endclass.

*---------------------------------------------------------------------*
*       CLASS lcl_text_edit IMPLEMENTATION
*---------------------------------------------------------------------*
class lcl_text_edit implementation.

  method constructor.
    call method super->constructor( parent = im_parent ).
  endmethod.

  method customeventhandle.

    wa_text = 'Appended Line'.
    append wa_text to textlines.

    call method me->set_text_as_r3table
       exporting
             table              = textlines
       exceptions
             others             = 1.

  endmethod.

endclass.

data: container type ref to cl_gui_custom_container.
data: textedit type ref to lcl_text_edit.

start-of-selection.

  call screen 100.
*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
module status_0100 output.
*  SET PF-STATUS 'xxxxxxxx'.
*  SET TITLEBAR 'xxx'.

  create object:

          container
              exporting container_name = 'CONTAINER',

          textedit
              exporting
                   im_parent     = container.


  call method textedit->register_event_dblclick.

  set handler textedit->customeventhandle for textedit.

endmodule.
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
module user_command_0100 input.

endmodule.

Regards,

Rich Heilman

Message was edited by: Rich Heilman

Message was edited by: Rich Heilman

Read only

0 Likes
1,808

.

Read only

0 Likes
1,808

Hi Poornanand,

I partially agree with you. Usually we donot come across user-defined events. But,it is very much possible to trigger user-defined events in your program and it is as simple in triggering as the already existing events.

Regards,

Vara

Read only

0 Likes
1,808

Hello Vamsi,

Seems like there was some miscommunication. Well let me ask you a question. Let us say I have a custom-control on my screen, say an ALV Grid. Now apart from the events that are defined for the class, I would like to add one more event. Now is it possible to achieve the F1 Functionality for the Escape Key? As far as I know, that is not possible. If you think it is possible, then please do share the trick.

And regarding user-defined events, I know that we can only add new events which do not have anything to do with the front-end (in the sense of my question above). Do you agree?

Regards,

Anand Mandalika.

Read only

0 Likes
1,808

Hi Poornanand Mandalika,

I actually wanted to say that user defined events can be triggered in ABAP Program. SAP provided us with standard events like F1, F4 or Hotspot click etc...

But these events are recognised by GuiXt. Now coming to User defined events. They are explicitly raised by the user. These events are not dependent on GuiXt. Thus events like F1, F4 and Hotspot click cannot be recognised by the user events (in OO context). Thus in your case we cannot handle such events.

I just gave an insight of the events in OO programming. That's all. This is not to mislead anyone.

Regards,

Vara