【问题标题】:How in OpenEdge ABL / Progress 4GL do I get the RIGHT-MOUSE-CLICK trigger to perform the default left click to reposition the focus如何在 OpenEdge ABL / Progress 4GL 中获得 RIGHT-MOUSE-CLICK 触发器来执行默认的左键单击以重新定位焦点
【发布时间】:2012-06-12 21:37:23
【问题描述】:

我正在使用 OpenEdge ABL / Progress 4GL。我有一个填充了行的浏览器小部件。当我左键单击一行时,该行突出显示,该行现在成为焦点。我希望当我右键单击不同的行以执行“左键单击”(将焦点移动到右键单击的行)然后右键单击。

【问题讨论】:

    标签: right-click progress-4gl openedge


    【解决方案1】:

    检查鼠标事件的 ABL 参考(10.2B ABL 参考指南的第 1834 页)。

    通常的方法是使用“ON event-name OF widget-name”捕获有问题的事件,然后将不同的事件应用于小部件(将“mouse-select-click”应用于 b-name)然后告诉AVM 使用“RETURN NO-APPLY”忽略原始事件。

    它看起来像这样:

    ON MOUSE-MENU-CLICK   OF b-name
       DO:
       APPLY "mouse-select-click" TO SELF.
       RETURN NO-APPLY.
       END.
    

    警告:我不确定右键单击会触发什么事件,因此您需要调整此代码以适应。

    【讨论】:

      【解决方案2】:

      我已经在这里回答了这个问题:How in OpenEdge ABL / Progress 4GL do I find the row id of a row that is right clicked in a browser.

      我不确定这个重复问题的政策是什么,但我在这里重复我的回答,希望没问题。

      我也有类似的情况;我想在浏览中响应鼠标的右键单击。右键单击不会选择您正在单击的行,因此我必须以编程方式确定它是哪一行。下面的编码确定您单击并选择了哪一行。恐怕真的有这么复杂。

      这发生在浏览的 MOUSE-MENU-DOWN 事件中:

      DEFINE VARIABLE iRowHeight   AS INTEGER     NO-UNDO.
      DEFINE VARIABLE iLastY       AS INTEGER     NO-UNDO.
      DEFINE VARIABLE iRow         AS INTEGER     NO-UNDO.
      DEFINE VARIABLE hCell        AS HANDLE      NO-UNDO.
      DEFINE VARIABLE iTopRowY     AS INTEGER     NO-UNDO.
      
      /* See if there are ANY rows in view... */
      IF SELF:NUM-ITERATIONS = 0 THEN 
      DO:
         /* No rows, the user clicked on an empty browse widget */
         RETURN NO-APPLY. 
      END.
      
      /* We don't know which row was clicked on, we have to calculate it from the mouse coordinates and the row heights. No really. */
      SELF:SELECT-ROW(1).               /* Select the first row so we can get the first cell. */
      hCell      = SELF:FIRST-COLUMN.   /* Get the first cell so we can get the Y coord of the first row, and the height of cells. */
      iTopRowY   = hCell:Y - 1.         /* The Y coord of the top of the top row relative to the browse widget. Had to subtract 1 pixel to get it accurate. */
      iRowHeight = hCell:HEIGHT-PIXELS. /* SELF:ROW-HEIGHT-PIXELS is not the same as hCell:HEIGHT-PIXELS for some reason */
      iLastY     = LAST-EVENT:Y.        /* The Y position of the mouse event (relative to the browse widget) */
      
      /* calculate which row was clicked. Truncate so that it doesn't round clicks past the middle of the row up to the next row. */
      iRow       = 1 + TRUNCATE((iLastY - iTopRowY) / iRowHeight, 0). 
      
      IF iRow > 0 AND iRow <= SELF:NUM-ITERATIONS THEN 
      DO:
        /* The user clicked on a populated row */
        Your coding here, for example:
        SELF:SELECT-ROW(iRow).
      END.
      ELSE DO:
        /* The click was on an empty row. */
        SELF:DESELECT-ROWS().
        RETURN NO-APPLY.
      END.
      

      我希望这会有所帮助。

      【讨论】:

        【解决方案3】:

        基本上,您必须像这样定义触发器:

        ON RIGHT-MOUSE-CLICK OF myBrowseRow DO:  
        
        APPLY "ENTRY" TO myBrowse IN FRAME myFrame.  
        
        /* Code to focus a particular row in the browse. */  
        APPLY "ENTRY" TO SELF IN BROWSE myBrowse.
        END.
        

        问题可能是您必须将该触发器添加到浏览器中的每一行,因为如果您仅为浏览器本身设置触发器,AFAIK 无法确定右键单击了哪一行...

        【讨论】:

        • 这不会将浏览的焦点更改为右键单击的行。你知道我该怎么做吗?
        • 实际上,APPLY "ENTRY" 行应该这样做。可能是APPLY ENTRY TO SELF 不起作用,不妨试试APPLY ENTRY TO myBrowseRow
        • 正如蒂姆的解决方案指出的那样,您需要在应用“条目”后“返回不适用”。否则,右键单击将是最后应用的事件。
        【解决方案4】:

        为了扩展主要答案,这里有一些附加说明和示例代码。
        1.您需要注意标题和标题的高度。
        2. 如果您有标准浏览功能,您可以动态附加菜单。
        3. 多选浏览器的行为略有不同。

        ON 'right-mouse-down':U ANYWHERE DO:
            RUN set_focus (SELF).
            IF SELF:TYPE = 'BROWSE' THEN DO:
                RETURN NO-APPLY.
            END.
            ELSE DO:
                APPLY 'menu-drop' TO SELF.
            END.
        END.
        
        PROCEDURE set_focus.
        DEF INPUT PARAM i_object            AS HANDLE   NO-UNDO.
        DEF VAR l_was_row_one_selected      AS LOG      NO-UNDO.
        DEF VAR l_header_y                  AS DEC      NO-UNDO.
        DEF VAR w_browse_title_bar_height   AS DEC      NO-UNDO INITIAL 19. /* determine this for your UI */
        DEF VAR o_labels                    AS CHAR     NO-UNDO.
        DEF VAR o_procedures                AS CHAR     NO-UNDO.
        DEF VAR h_menu                      AS HANDLE   NO-UNDO.
        DEF VAR h_menu_item                 AS HANDLE   NO-UNDO.
        DEF VAR l_count                     AS INT      NO-UNDO.
        /* given an object ... */
            IF i_object:TYPE = 'browse' THEN DO:
                IF i_object:NUM-SELECTED-ROWS = 0
                    THEN ASSIGN l_was_row_one_selected = FALSE.
                    ELSE ASSIGN l_was_row_one_selected = i_object:IS-ROW-SELECTED(1) NO-ERROR.
                i_object:SELECT-ROW(1) NO-ERROR.
                IF ERROR-STATUS:ERROR THEN RETURN.
                l_header_y = MAX(1,i_object:FIRST-COLUMN:Y). /* in case there are no column headers */
                IF i_object:TITLE <> ? THEN l_header_y = l_header_y - w_browse_title_bar_height.
                IF l_was_row_one_selected = FALSE THEN i_object:DESELECT-SELECTED-ROW(1) NO-ERROR.
                /* this section selects the correct row, based on where it was clicked, minus the height of the headers divided by row height */
                i_object:SELECT-ROW(
                    INT(
                        1 + 
                        TRUNC(
                              (LAST-EVENT:Y - l_header_y) / i_object:FIRST-COLUMN:HEIGHT-PIXELS
                             ,0)
                        )
                    )
                    NO-ERROR.
                APPLY 'ENTRY':u TO i_object. /* to get focus properly */
                APPLY 'VALUE-CHANGED':u TO i_object.
                /* use some rule to find associated dynamic menu items, e.g. maintenance options, finding related data*/
                RUN find_menu_stuff (i_object:NAME, OUTPUT o_labels, OUTPUT o_procedures).
                IF o_labels = '' THEN RETURN.
        
                /* this finds a popup menu, if any */
                h_menu = i_object:POPUP-MENU NO-ERROR.
        
                IF VALID-HANDLE(h_menu) THEN RETURN. /* already created previously */
                /* create a popup menu */
                CREATE MENU h_menu.
                ASSIGN
                    h_menu:POPUP-ONLY   = TRUE
                    i_object:POPUP-MENU = h_menu
                    .
                /* add the standard maintenance options (they still may not be supported though) */
                DO l_count = 1 TO NUM-ENTRIES (o_labels):
                    IF ENTRY(l_count,o_labels) = 'Rule' THEN DO:
                        CREATE MENU-ITEM h_menu_item
                            ASSIGN
                                SUBTYPE     = 'RULE'
                                PARENT      = h_menu
                                .
        
                    END.
                    ELSE DO:
                        CREATE MENU-ITEM h_menu_item
                            ASSIGN
                                PARENT      = h_menu
                                LABEL       = ENTRY(l_count,o_labels)
                                SENSITIVE   = TRUE
                            TRIGGERS:
                                ON CHOOSE PERSISTENT RUN pp_apply_maint_action IN THIS-PROCEDURE (SELF, ENTRY(l_count,o_procedures)).
                            END TRIGGERS.
                    END.
                END.
            END.
            IF VALID-HANDLE(h_menu)
                THEN APPLY 'menu-drop' TO h_menu.
            /* MENU-DROP - Supported only when the POPUP-ONLY attribute is set to TRUE and the
                           menu is set as a popup for some other widget */
        END PROCEDURE.
        
        PROCEDURE find_menu_stuff.
            /* do lookups or other general or specific things here */
        END.
        

        【讨论】:

        • 感谢您的帮助!我有一个浏览器应用程序。有没有办法设置一个虚拟浏览器来设置弹出菜单?我指的是注释行:“MENU-DROP - 仅当 POPUP-ONLY 属性设置为 TRUE 并且菜单设置为其他小部件的弹出窗口时才支持”。再次感谢!
        猜你喜欢
        • 2014-03-19
        • 2012-03-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-10-08
        相关资源
        最近更新 更多