2005 Feb 25 1:58 PM
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?
2005 Feb 25 3:30 PM
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
2005 Feb 25 5:22 PM
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.
2005 Feb 28 11:19 AM
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
2005 Feb 28 11:32 AM
2005 Feb 28 11:54 AM
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
2005 Feb 28 11:59 AM
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.
2005 Feb 28 12:04 PM
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
2005 Feb 28 12:17 PM
2005 Feb 28 12:24 PM
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
2005 Feb 28 1:00 PM
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.
2005 Mar 01 1:51 PM
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
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |