在方法中获取按钮工具提示

Getting button tooltip in method

在我的 webdynpro 中,当我单击一个按钮时,我不想获取按钮的工具提示并将其用作 pop-up window.

的标题
method WDDOMODIFYVIEW .
  "write view to attribute so it can be accessed from other methods.
  wd_this->DETAILVIEW = view.
endmethod.

.

method ONACTIONOPENDIALOG .
  data lv_title type string.
  data lv_buttonID type string.
  data lv_button type ref to if_wd_view_element.
  buttonID = wdevent->get_string( name = 'ID' ).
  button = wd_this->detailview->get_element( lv_buttonid ).

  call method cl_fitv_wd_util=>UI_GET_PROPERTY(
    exporting
      io_view = wd_this->detailview
      io_view_element = lv_button
      iv_id = buttonid
      iv_property_name = 'TOOLTIP'
      importing
      ev_value = lv_title ).

  wd_this->dopopup( title = lv_title ).
endmethod.

方法UI_GET_PROPERTY无法获取工具提示。可能是因为它试图在 if_wd_view_element 而不是 cl_wd_button 上调用方法 GET_TOOLTIP。这是此方法中的错误吗? 有没有办法将 if_wd_view_element 转换为 cl_wd_button?

ref to if_wd_view_element 可以向下转换为 ref to cl_wd_uielement。向下转换为 cl_wd_button 也适用于按钮,但不适用于工具栏按钮。 cl_wd_uielement 可能适用于所有 uielements。

method ONACTIONOPENDIALOG .
  data lv_title type string.
  data lv_buttonID type string.
  data lv_button type ref to if_wd_view_element.
  data lv_realbutton type ref to cl_wd_uielement.

  lv_buttonID = wdevent->get_string( name = 'ID' ).
  lv_button = wd_this->detailview->get_element( lv_buttonid ).

  "downcast view_element to uielement
  lv_realbutton ?= lv_button.
  lv_title = lv_realbutton->get_tooltip( ).

  selectbuttonrow( exporting actionevent = wdevent ).
  wd_this->dopopup( title = lv_title ).
endmethod.

我在这里找到了一篇关于向下转型的文章:https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abapmove_cast.htm