05-26-2008 7:46 AM
Hello,
I have a screen with a text field containing a material document number. I have enabled double-clicks on this text field by setting the 'Resp. to DblClk' check box. However, I still don't know how to handle events for double clicks. I mean when I double-click the text field, how do I identify the event-type and the source of the event. As far as I know, there is no way to set a function code value for a text field.
Please reply ASAP.
Thanks and regards,
Divyaman Singh Rawat
05-26-2008 7:53 AM
instead of double click ...u create a pushbutton near to that
if it is usefull Plz Reward
Regards
Anbu
05-26-2008 11:08 AM
it is related with container class and text object please refer this which help u to double clik and handle event,
05-26-2008 1:32 PM
Provided you have the PF-Status containing a function code for the F2 / double-click selection you should be able to pick up this action in your PAI user command logic - if you use the "get cursor field" command you can tell where the cursor was when the user selected the action and react accordingly.
Jonathan
05-26-2008 2:19 PM
Hi Jonathan,
Thanks for your response! I am already using the F2 function key for some other purpose. Is is possible to assign the funtion code to a different function key? Also, how to I associate the function with the double click event?
Regards,
Divyaman
05-26-2008 11:43 PM
F2 is traditionally "pick" or "select" or "drilldown" and the SAPGui will issue an F2 if you double-click on a field... but even if you are already using it for other purposes by using the "get cursor field" you can distinguish where the user was drilling into and react accordingly i.e. use existing logic unless the field they are on is the one exception you want to have special processing for.
Jonathan
05-27-2008 6:21 AM
this code might help u..
When you double click on a text line in the TextEdit control, you want it to be prefixed with a '*'.
The line number of the TextEdit control that is double clicked, is retreived using method GET_SELECTION_POS. The internal text table is reloaded froim the TextEdit control with method GET_TEXT_AS_R3TABLE. The position of the double click in the TextEdit control is used to find the entry in the table, and the entry is prefixed with '*' and loaded into the TextEdit control again.
The program should be changed so that the internal table i_texttable is global, and a global flag g_loaded added. The load of the table should be moved to the PBO module. The changes in thje code are marked with red. The whole program now looks like this:
Code
REPORT sapmz_hf_controls1 .
CONSTANTS:
line_length TYPE i VALUE 254.
DATA: ok_code LIKE sy-ucomm.
DATA:
Create reference to the custom container
custom_container TYPE REF TO cl_gui_custom_container,
Create reference to the TextEdit control
editor TYPE REF TO cl_gui_textedit,
repid LIKE sy-repid.
**********************************************************************
Utillity table to load texts
**********************************************************************
TYPES:
BEGIN OF t_texttable,
line(line_length) TYPE c,
END OF t_texttable.
DATA:
i_texttable TYPE TABLE OF t_texttable,
g_loaded(1) TYPE c.
**********************************************************************
Impmenting events
**********************************************************************
DATA:
event_type(20) TYPE c,
Internal table for events that should be registred
i_events TYPE cntl_simple_events,
Structure for oneline of the table
wa_events TYPE cntl_simple_event.
----
CLASS lcl_event_handler DEFINITION
----
CLASS lcl_event_handler DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
catch_dblclick FOR EVENT dblclick
OF cl_gui_textedit IMPORTING sender.
ENDCLASS.
CLASS lcl_event_handler IMPLEMENTATION.
METHOD catch_dblclick.
DATA:
from_line TYPE i,
from_pos TYPE i,
to_line TYPE i,
to_pos TYPE i,
wa_texttable TYPE t_texttable.
Used for the sytem event
call method cl_gui_cfw=>set_new_ok_code
exporting new_code = 'SHOW'.
Read the position of the double click
CALL METHOD sender->get_selection_pos
IMPORTING
from_line = from_line
from_pos = from_pos
to_line = to_line
to_pos = to_pos.
Texts in the TextEdit control can have been changed, so
first reload text from the control into the internal
table that contains text
IF NOT g_loaded IS INITIAL.
CALL METHOD sender->get_text_as_r3table
IMPORTING table = i_texttable.
Read the line of the internal table that was clicked
READ TABLE i_texttable INDEX from_line INTO wa_texttable.
IF sy-subrc <> 0.
EXIT.
ENDIF.
IF wa_texttable+0(1) CS '*'.
SHIFT wa_texttable.
ELSEIF wa_texttable+0(1) NS '*'.
SHIFT wa_texttable RIGHT.
wa_texttable+0(1) = '*'.
ENDIF.
modify i_texttable from wa_texttable index from_line.
Reload texts from h einternal table
perform load_texts.
ENDIF.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
CLEAR wa_events.
REFRESH: i_events.
SET SCREEN '100'.
----
MODULE USER_COMMAND_0100 INPUT *
----
MODULE user_command_0100 INPUT.
CASE ok_code.
WHEN 'EXIT'.
LEAVE TO SCREEN 0.
WHEN 'SHOW'.
event_type = 'System dblclick'.
WHEN 'IMP'.
PERFORM Load_texts.
WHEN OTHERS.
CALL METHOD cl_gui_cfw=>dispatch. "Not used for system events
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
&----
*& Module STATUS_0100 OUTPUT
&----
MODULE status_0100 OUTPUT.
The TextEdit control shoul only be initialized the first time the
PBO module executes
IF editor IS INITIAL.
repid = sy-repid.
Create object for custom container
CREATE OBJECT custom_container
EXPORTING
container_name = 'MYCONTAINER1'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
others = 6
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Create obejct for the TextEditor control
CREATE OBJECT editor
EXPORTING
wordwrap_mode =
cl_gui_textedit=>wordwrap_at_fixed_position
wordwrap_position = line_length
wordwrap_to_linebreak_mode = cl_gui_textedit=>true
parent = custom_container
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
gui_type_not_supported = 5
others = 6
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Link the event handler method to the event and the
TextEdit control
SET HANDLER lcl_event_handler=>catch_dblclick FOR editor.
Register the event in the internal table i_events
wa_events-eventid = cl_gui_textedit=>event_double_click.
wa_events-appl_event = 'X'. "This is an application event
wa_events-appl_event = space. "This is a system event
APPEND wa_events TO i_events.
Pass the table to the TextEdit control uding method
set_registred_events
CALL METHOD editor->set_registered_events
EXPORTING events = i_events.
Create internal table with texts taht can be uploaded to
the TextEdit control
APPEND 'This a method that fills the TextEdit control' TO i_texttable.
APPEND 'with a text.' TO i_texttable.
DO 10 TIMES.
APPEND 'hallo world !' TO i_texttable.
ENDDO.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
&----
*& Form Load_texts
&----
This form loads the lines of the internal table i_texttable into
the TextEdit control
----
FORM Load_texts.
Load TextEdit control with texts
CALL METHOD editor->set_text_as_r3table
EXPORTING table = i_texttable.
IF sy-subrc > 0.
Display an error message
EXIT.
ENDIF.
All methods that operates on controls are transferred to the frontend
by a RFC calls. the method FLUSH is used to determine when this is
done.
CALL METHOD cl_gui_cfw=>flush.
IF sy-subrc > 0.
Display an error message
ENDIF.
g_loaded = 'X'.
ENDFORM. " create_texts
fatch points if its helping thxx