Search code examples
cobol

Clickable grid instead of editable


I have a grid with screen settings like this:

02 SCR-KUN-LST-1.
    03 SCR-KUN-LISTE GRID PAGED SIZE 145 LINES 21 3-D
        LINE 1 COL 1,25 FONT SMALL-FONT
        RECORD-DATA        = KUN-LISTE-LINJE
        DATA-COLUMNS    = (1 11 12 62 112 142 157 172 187 237 252)
        DISPLAY-COLUMNS = (1 10 12 40 65 86 99 112 125 135)
        ALIGNMENT = ("L","C","L","L","L","L","L","L","L","L")
        ROW-DIVIDERS       = (1,1)
        COLUMN-DIVIDERS    = (1,1)
        DIVIDER-COLOR      = 32 
        CURSOR-COLOR       = 80
        HEADING-MENU-POPUP 63
        HEADING-COLOR      = 256
        CURSOR-FRAME-WIDTH = -1
        NUM-ROWS           = 0
        VPADDING           = 50
        VIRTUAL-WIDTH      = 155
        VSCROLL ADJUSTABLE-COLUMNS USE-TAB 
        BOXED BORDER-COLOR BLACK
        REORDERING-COLUMNS SORTABLE-COLUMNS
        COLUMN-HEADINGS CENTERED-HEADINGS TILED-HEADINGS
        POP-UP MENU KUN-MENU     
        ID IS 209 BEFORE PROCEDURE IS VIS-KOMMENTAR 
        EVENT PROCEDURE KUN-LISTE-SAVE
        EXCEPTION PROCEDURE KUN-LISTE-EVENTS.

When running the grid, it is loaded with the columns etc., but when I click/double click it comes in a editor mode. I want the grid to handle double click as a function to open a line instead.

Anyone have an idea of what I can do to do that? Let me know if you need more code to see it better.


Solution

  • You're looking for the ENTRY-REASON special property on GRID elements.

    https://supportline.microfocus.com/documentation/acucorpproducts/docs/v6_online_doc/gtman2/gt2546.htm

    ENTRY-REASON (alphanumeric)

    This property records the user's action that caused the grid to shift to entry mode. It is set immediately before the MSG-BEGIN-ENTRY event is generated, and it is retained until overwritten by another MSG-BEGIN-ENTRY event or until the grid is destroyed.

    The encoding is a single PIC X character as follows:

    x"00"
    A X"00" (binary 0, ASCII null) value indicates that the user double-clicked on the cell

    x"0D"
    A X"0D" (binary 13, ASCII carriage-return) value indicates that the user pressed the key Otherwise Any other value is the key that the user pressed. For example, if the user started typing "John," then the letter "J" is returned by ENTRY-REASON.

    ENTRY-REASON can be only inquired. Setting it has no effect. You may inquire on ENTRY-REASON during a MSG-BEGIN-ENTRY event to determine what caused the current entry to start. Note that you can then prohibit entry if you desire by moving EVENT-ACTION-FAIL to EVENT-ACTION and returning from the event procedure.

    Given that, and your given code, your KUN-LISTE-SAVE paragraph could have

    KUN-LISTE-SAVE.
        EVALUATE EVENT-TYPE
           WHEN MSG-BEGIN-ENTRY
              INQUIRE SCR-KUN-LISTE ENTRY-REASON = YOUR-ENTRY-REASON
              IF YOUR-ENTRY-REASON = X"00"
                PERFORM YOUR-ON-DBL-CLICK
              END-IF
        END-EVALUATE.