作者:默默追寻爱情 | 来源:互联网 | 2023-08-30 19:04
1.17UIElement:ContextMenu使用本实例测试创建ContextMenu.1.创建Component,View:V_CONTEXT_MENU;2.创建Contex
1.17 UI Element:Context Menu使用
本实例测试创建Context Menu.
1.创建Component,View: V_CONTEXT_MENU;
2.创建Context节点;
创建Node:NODE_TV,Cardinality:1..1;
创建Attribute:TV1,类型String;
创建Node:NODE_ATTR,Cardinality:1..1;
创建Attribute:MENU_CHK, 类型WDY_BOOLEAN;
创建Attribute:MENU_RADIOBTN,类型WDR_DEMO_FRUIT;
创建Attribute:MENU_CHK1,类型WDY_BOOLEAN;
3.创建Layout页签;
创建UI Element:MenuBar,ID:MENUBAR;
创建UI Element:Menu,ID:MENU;
创建UI Element:Menu,ID:MENU_SUB1;
创建UI Element:MenuActionItem,ID: MENU_CHG,绑定Action: MENU_CHG;
创建UI Element:MenuActionItem,ID: MENU_ADD,绑定Action:MENU_ADD;
创建UI Element:MenuSeparator,ID:MENU_SEP1;
创建UI Element:Menu,ID:MENU_SUB2;
创建UI Element:MenuRadioButton,ID:MENU_BTN,绑定Action: MENU_SEL,selectedKey绑定Context的Attributes: V_CONTEXT_MENU.NODE_ATTR.MENU_RADIOBTN;
创建UI Element:MenuRadioButton,ID:MENU_BTN1,绑定Action:MENU_SEL,selectedKey绑定Context的Attributes: V_CONTEXT_MENU.NODE_ATTR.MENU_RADIOBTN;
创建UI Element:MenuSeparator,ID:MENU_SEP2;
创建UI Element:Menu,ID:MENU_SUB3;
创建UI Element:MenuCheckBox,ID:MENU_CHK,绑定Action:MENU_TOG,checked绑定Context的Attributes: V_CONTEXT_MENU.NODE_ATTR.MENU_CHK;
创建UI Element:MenuCheckBox,ID:MENU_CHK1,绑定Action:MENU_TOG,checked绑定Context的Attributes: V_CONTEXT_MENU.NODE_ATTR.MENU_CHK1;
创建UI Element:TextView,text绑定Context的Attributes: V_CONTEXT_MENU.NODE_TV.TV1;
4.创建Method页签,实现Action方法;
实现Action: MENU_ADD,Menu选择Add;
代码实例:
DATA:lo_node TYPE REF TO if_wd_context_node.
DATA:lo_element TYPE REF TO if_wd_context_element.
lo_node = wd_context->get_child_node( wd_this->wdctx_node_tv ).
lo_element = lo_node->get_element( ).
lo_element->set_attribute(
EXPORTING
name = 'TV1'
value = 'Menu:add'
).
实现Action:MENU_CHG,Menu选择change;
DATA:lo_node TYPE REF TO if_wd_context_node.
DATA:lo_element TYPE REF TO if_wd_context_element.
lo_node = wd_context->get_child_node( wd_this->wdctx_node_tv ).
lo_element = lo_node->get_element( ).
lo_element->set_attribute(
EXPORTING
name = 'TV1'
value = 'Menu:change'
).
实现Action:MENU_SEL,Menu选择Radio Button;
代码实例:
DATA:lo_node TYPE REF TO if_wd_context_node.
DATA:lo_element TYPE REF TO if_wd_context_element.
DATA:lo_event TYPE REF TO cl_wd_custom_event.
DATA:lv_string TYPE string.
lo_event = wdevent.
lv_string = lo_event->get_string( name = 'KEY' ).
lv_string = 'Menu:radio button,' && lv_string.
lo_node = wd_context->get_child_node( wd_this->wdctx_node_tv ).
lo_element = lo_node->get_element( ).
lo_element->set_attribute(
EXPORTING
name = 'TV1'
value = lv_string
).
实现Action:MENU_TOG,CheckBox选择事件;
代码实例:
DATA:lo_node TYPE REF TO if_wd_context_node.
DATA:lo_element TYPE REF TO if_wd_context_element.
DATA:lo_event TYPE REF TO cl_wd_custom_event.
DATA:lv_id TYPE string.
lo_event = wdevent.
lv_id = lo_event->get_string( name = 'ID' ).
lv_id = 'Menu:checkbox' && lv_id.
lo_node = wd_context->get_child_node( wd_this->wdctx_node_tv ).
lo_element = lo_node->get_element( ).
lo_element->set_attribute(
EXPORTING
name = 'TV1'
value = lv_id
).
本文来自博客园,作者:渔歌晚唱,转载请注明原文链接:https://www.cnblogs.com/tangToms/p/16630529.html