进阶:案例六: Context Menu(静态 与 动态)

实现:

1、add:

进阶:案例六: Context Menu(静态 与 动态)

2、delete

进阶:案例六: Context Menu(静态 与 动态)

3、add2

进阶:案例六: Context Menu(静态 与 动态)

实现步骤:

1、新建属性display_text

2、创建layout

进阶:案例六: Context Menu(静态 与 动态)

3、代码部分:

add事件:

METHOD onactionadd .
DATA: ls_disp TYPE string.
wd_context->get_attribute(
EXPORTING name = 'DISPLAY_TEXT'
IMPORTING value = ls_disp ).
CONCATENATE ls_disp 'Action1' into ls_disp.
wd_Context->SET_ATTRIBUTE( name = 'DISPLAY_TEXT' value = ls_disp ). ENDMETHOD.

add2事件:

method ONACTIONADD2 .
data: ls_disp type string.
wd_Context->get_attribute(
EXPORTING name = 'DISPLAY_TEXT'
IMPORTING value = ls_disp ).
CONCATENATE ls_disp 'Action2' into ls_disp.
wd_Context->SET_ATTRIBUTE( name = 'DISPLAY_TEXT' value = ls_disp ).
endmethod.

delete事件:

method ONACTIONDELETE .
data: ls_disp type string.
wd_Context->SET_ATTRIBUTE( name = 'DISPLAY_TEXT' value = space ).
endmethod.

方法WDDOONCONTEXTMENU好像没起作用

method WDDOONCONTEXTMENU .
DATA: ls_id type string,
lo_menu type REF TO cl_wd_menu,
lo_menu_item type REF TO cl_wd_menu_action_item.
* get the UI element ID
ls_id = CONTEXT_MENU_EVENT->originator->id.
* if it is the 1st UI,then assign the Cotext Menu statically
IF ls_id = 'TEXT'.
MENU = CONTEXT_MENU_MANAGER->get_context_menu( 'ACTION' ).
ENDIF.
* if it is the 2nd UI,then assign the Cotext Menu programly
IF ls_id = 'TEXT2'.
**runtime object
lo_menu = cl_wd_menu=>new_menu( id = 'ACTION2' ).
**menu itme
lo_menu_item = cl_wd_menu_action_item=>new_menu_action_item(
id = 'ADD2'
on_action = 'ADD2'
text = 'Action2-Add2' ).
**add this item to menu
lo_menu->add_item( lo_menu_item ).
**menu itme
lo_menu_item = cl_wd_menu_action_item=>new_menu_action_item(
id = 'DELETE2'
on_action = 'DELETE'
text = 'Action2-DELETE2' ).
**add this item to menu
lo_menu->add_item( lo_menu_item ).
**return the menu
MENU = lo_menu.
ENDIF.
endmethod.
上一篇:linux中的权限对于文件和目录的重要性


下一篇:使用Sublime Text搭建python调试环境