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

Problems with cl_gui_textedit->set_focus

Former Member
0 Likes
1,094

I tried to set focus on my cl_gui_textedit control programmatically in pbo of my dynpro.

But it doesn't work.

Here's my code.

CALL METHOD editor1->set_readonly_mode
   EXPORTING readonly_mode = cl_gui_textedit=>false.

CALL METHOD editor1->set_focus
   EXPORTING
     control = editor1.

CALL METHOD cl_gui_cfw=>flush.

CALL METHOD editor->SET_SELECTION_POS_IN_LINE
 EXPORTING pos = 5
           line = 1.

I almost tried everything.

I tried to set focus on my cl_gui_textedit control programmatically in pbo of my dynpro.

But it doesn't work.

Here's my code.

CALL METHOD editor1->set_readonly_mode
   EXPORTING readonly_mode = cl_gui_textedit=>false.

CALL METHOD editor1->set_focus
   EXPORTING
     control = editor1.

CALL METHOD cl_gui_cfw=>flush.

CALL METHOD editor->SET_SELECTION_POS_IN_LINE
 EXPORTING pos = 5
           line = 1.

I almost tried everything.

6 REPLIES 6
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
953

I tried to set focus on my cl_gui_textedit control programmatically in pbo of my dynpro.

But it doesn't work.


CALL METHOD editor1->set_readonly_mode  "here you have mentioned editor1
   EXPORTING readonly_mode = cl_gui_textedit=>false.
 
CALL METHOD editor1->set_focus   "here you have mentioned editor1
   EXPORTING
     control = editor1.
 
CALL METHOD cl_gui_cfw=>flush.
 
CALL METHOD editor->SET_SELECTION_POS_IN_LINE  "here you have mentioned editor
 EXPORTING pos = 5
           line = 1.

So is it editor or editor1 ?. Hope you understood the problem.

Kesav

Read only

0 Likes
953

It is the editor1 .

CALL METHOD editor1->set_readonly_mode  "here you have mentioned editor
   EXPORTING readonly_mode = cl_gui_textedit=>false.


CALL METHOD editor1->set_focus   "here you have mentioned editor1
   EXPORTING
     control = editor1.


CALL METHOD cl_gui_cfw=>flush.


CALL METHOD editor1->SET_SELECTION_POS_IN_LINE  "here you have mentioned editor  EXPORTING pos = 5
           line = 1.

Read only

0 Likes
953

Hi,

In your previous post you have mentioned editor and editor1 , so i assumed the problem would be because of that. If it was a typo then now whatever you have written is correct and it should work. Here is a piece of code which works for me.


REPORT yvariant_text .
PARAMETERS:pa TYPE c.
DATA: container TYPE REF TO cl_gui_docking_container,
      editor    TYPE REF TO cl_gui_textedit,
      report    TYPE syrepid.

DATA:tlines    TYPE TABLE OF tdline,
     wa_tlines TYPE tdline.

AT SELECTION-SCREEN OUTPUT.
  report = sy-repid.
  IF container IS INITIAL.
    CREATE OBJECT container
                 EXPORTING repid     = report
                           dynnr     = sy-dynnr
                           side      = container->dock_at_left
                           extension = 1070.
    CREATE OBJECT editor
                EXPORTING
                     parent     = container.
  ENDIF.
  wa_tlines = 'This is first line in the edit control'.
  APPEND wa_tlines TO tlines.
  wa_tlines = 'This is second line in the edit control'.
  APPEND wa_tlines TO tlines.
  CALL METHOD editor->set_text_as_r3table
     EXPORTING
           table              =  tlines
     EXCEPTIONS
           OTHERS             = 1.
  CALL METHOD editor->set_focus
     EXPORTING
       control = editor.
  CALL METHOD editor->set_selection_pos_in_line
   EXPORTING pos = 5
             line = 2.

Read only

0 Likes
953

I tried your code, but it doesn't work.

Which version of SAP GUI do you use?

We us 7.02.

Maybe it's a bug?

thx

Read only

0 Likes
953

I use 4.7 & surely its not a bug. Place this code in SE38 sample program and check. You should be missing something in your code

Kesav

Read only

0 Likes
953

Hey

Yeah actually i tested exactly what you mentioned. But as i said, it doesn't work...

The Cursor will NOT jump into the Textedit.

It is a mistery.