cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic textview with menu

Former Member
0 Kudos

Hi all,

I am trying to code a dynamic textview with a menu.

So the point of it would be to click on the textview and get a menu that pops open under the textview.

The menu is an ui element, and when I make it statically everything goes well... but when I try this code, I don't get the menu...

Data lo_txv type ref to cl_wd_text_view.
Data lo_menu type ref to cl_wd_menu.
Data lo_menu_action_item type ref to cl_wd_menu_action_item.

lo_txv = cl_wd_text_view=>new_text_view( ID = 'TEST'  TEXT = 'TEXT' ).

lo_menu = cl_wd_menu=>new_menu( ID = 'MENU'    TITLE = 'TITLE' ).

lo_menu_action_item = cl_wd_menu_action_item=>new_action_item( ID = 'ITEM1' TEXT = 'ITEM1' ON_ACTION = 'EMPTY_ACTION' ).

lo_menu->add_item( lo_menu_action_item ).

lo_menu_action_item = cl_wd_menu_action_item=>new_action_item( ID = 'ITEM2' TEXT = 'ITEM2' ON_ACTION = 'EMPTY_ACTION' ).

lo_menu->add_item( lo_menu_action_item ).

lo_txv->set_menu( lo_menu )

.

This code should give me a textview with a menu with 2 items... but it doesn't.

Could someone please help me out ??

Thanks in Advance,

David Bellers

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi David,

I don't see code where you add the textview to your View? But I suppose you coded that as well..

Try to add LayoutData to your TextView (for example: MatrixHeadData)?

Regards,

Roelof

Former Member
0 Kudos

Thanks for your reply,

I didn't write the code down for the matrixlayout, but it is correctly implemented.

Do I have to add the view to the textview?

When programming dynamically I've never had to work with the view itself, most of the time,

I add the elements to a container and that container is in the view...

Just to have everything I'll change the code to do every exact step...


Data lo_txv type ref to cl_wd_text_view.
Data lo_menu type ref to cl_wd_menu.
Data lo_menu_action_item type ref to cl_wd_menu_action_item.
 
lo_txv = cl_wd_text_view=>new_text_view( ID = 'TEST'  TEXT = 'TEXT' ).
 
lo_menu = cl_wd_menu=>new_menu( ID = 'MENU'    TITLE = 'TITLE' ).
 
lo_menu_action_item = cl_wd_menu_action_item=>new_action_item( ID = 'ITEM1' TEXT = 'ITEM1' ON_ACTION = 'EMPTY_ACTION' ).
 
lo_menu->add_item( lo_menu_action_item ).
 
lo_menu_action_item = cl_wd_menu_action_item=>new_action_item( ID = 'ITEM2' TEXT = 'ITEM2' ON_ACTION = 'EMPTY_ACTION' ).
 
lo_menu->add_item( lo_menu_action_item ).

lo_txv->set_menu( lo_menu ).

cl_wd_matrix_head_data=>new_matrix_head_data( element = lo_xv ).

container->add_child( the_child = lo_txv ).

Former Member
0 Kudos

hi,

In my case using nw7.01, you need to implement the method WDDOONCONTEXTMENU ,

it has a returning parameter MENU.

You need to get your menu and assign to the retuning parameter MENU.

something like this

menu = cl_wd_menu=>get_menu( id = `MENU`).