ENTRY to Field in Dynamic Browse

In a nutshell, my goal is to apply ENTRY to the field the user double-clicked on (activating the dynamic editable browse).

However, I can’t seem to change the column manually at all. The field selected is always in the column last selected when the browse was active.

I have multiple strategies for turning the mouse click into the correct column, but I can’t test any of them because the final step of changing to the column always fails. I can’t even change it to a static column (like the fifth for example).

CURRENT-COLUMN? No luck.

“APPLY "ENTRY" TO [field name] IN BROWSE [browse-name]”? Well, my browse is dynamic and I can’t seem to get the syntax correct.

Help!
 

jkuhns

New Member
I just wrote a lot of code for dynamic browses, so I know the frustration. If you're going to work with more than one on a window, I'd suggest using temp tables to keep track of the handles and names. This will come in particularly handy if you want to use ROW-DISPLAY logic. For the task at hand, a procedure as follows will work just fine. Pass it the handle to the browse and the column name you want to select.
Code:
  DEF INPUT PARAM hBrowse AS HANDLE NO-UNDO.
  DEF INPUT PARAM cColName AS CHAR NO-UNDO.
  DEF VAR hCol AS HANDLE NO-UNDO.
  DEF VAR iIndex AS INT NO-UNDO.
  DO iIndex = 1 TO hBrowse:NUM-COLUMNS:
      IF hBrowse:GET-BROWSE-COLUMN(iIndex):NAME = cColName THEN DO:
          hCol = ttBrws.BrwsHdl:GET-BROWSE-COLUMN(iIndex).
          LEAVE.
      END.
  END.
  IF VALID-HANDLE(hCol) THEN
     APPLY "ENTRY" TO hCol.
END PROCEDURE.
Also, one word of warning, if you are using 10.1C or better and choose to use toggle box or combo box fields, the last-event:X coordinate is always wrong, and not in a way you can correct for. For example, 3 columns, all 100 pixels wide, the second is declared as a toggle box. The last-event:x coordinate for column 1 is 0 - 99, column 3 is 200-299, but the last-event:x for column 2 is always off, like 360-459. Add a fourth column the first three don't change, but your fourth column shows last-event:x of 300-499. If you figure out any work-arounds for that, I'd love to hear it.
 
Excellent! Somehow, I didn't stumble upon applying ENTRY directly to the ColumnHandle.

Here's a portion of my 'DEFAULT-ACTION' trigger to enable editing on the browse:

Code:
/* Highlight the column you clicked */
DO v-index = 1 TO BrowseHandle:NUM-COLUMNS:
    ASSIGN ColumnHandle = BrowseHandle:GET-BROWSE-COLUMN(v-index) NO-ERROR.
 
    IF VALID-HANDLE(ColumnHandle)
        AND NOT ColumnHandle:READ-ONLY
        AND v-lastXpixel < (ColumnHandle:X + ColumnHandle:WIDTH-PIXELS) THEN
    DO:
        APPLY "ENTRY" TO ColumnHandle.
        LEAVE.
    END.
END.
 
APPLY "ENTRY" TO BrowseHandle.

v-lastXpixel is gotten by the 'MOUSE-SELECT-DOWN' trigger.

I was getting a weird screen error if cancelled out of the edit before moving to another cell - too weird to try to explain. This was solved with the ENTRY to the BrowseHandle at the end. Whatever was different when my last ENTRY was to the column instead of the browse, I don't know exactly, but brute force solved it. Yay!
 
Top