Progress
Programming
Handbook


Browse Events

This section covers:

Basic Events

The basic browse events include:

Typically, you use the VALUE–CHANGED and DEFAULT–ACTION events to link your browse to other parts of your application, in the code example below, both events are used to handle displaying data that is not ideally suited for display in the browse. In this case, a supplemental editor widget is used to display the lengthy text strings found in the customer comments field.

The trigger on VALUE–CHANGED refreshes the data in the comments editor as you navigate through the browse. This type of trigger is often used to keep related data in the same frame or window in sync with a browse.

The trigger on DEFAULT–ACTION displays the comments editor in a dialog box that pops up when you double-click a browse row. One typical use of DEFAULT–ACTION triggers is to display a supplementary view of data related to the record, as the following code sample demonstrates:

p-br07.p
DEFINE VARIABLE credit-left AS DECIMAL LABEL "Credit Left". 
DEFINE QUERY q1 FOR customer SCROLLING. 
DEFINE BROWSE b1 QUERY q1 DISPLAY cust-num name credit-limit balance  
    (credit-limit - balance) @ credit-left 
    ENABLE credit-limit WITH 10 DOWN SEPARATORS  
    TITLE "Update Credit Limits". 
DEFINE BUTTON b-ok LABEL "OK" SIZE 20 BY 1. 
DEFINE FRAME f1 
    b1 skip(.5) 
    customer.comments VIEW-AS EDITOR INNER-LINES 3  
        INNER-CHARS 62 
        WITH SIDE-LABELS ROW 2 CENTERED NO-BOX. 
DEFINE FRAME f2 
    customer.comments NO-LABEL VIEW-AS EDITOR INNER-LINES 3  
        INNER-CHARS 62 SKIP(.5) 
    b-ok to 42 SKIP(.5) 
        WITH SIDE-LABELS ROW 2 CENTERED 
        VIEW-AS DIALOG-BOX TITLE "Comments".  
ON VALUE-CHANGED OF b1 
DO: 
    DISPLAY customer.comments WITH FRAME f1. 
END. 
ON DEFAULT-ACTION OF b1 
DO: 
    ASSIGN customer.comments:READ-ONLY IN FRAME f2 = TRUE.  
    DISPLAY customer.comments WITH FRAME f2. 
    ENABLE ALL WITH frame f2. 
    WAIT-FOR CHOOSE OF b-ok. 
    HIDE FRAME f2. 
END. 
ASSIGN customer.comments:READ-ONLY IN FRAME f1 = TRUE.  
OPEN QUERY q1 FOR EACH customer NO-LOCK. 
ENABLE ALL WITH FRAME f1. 
WAIT-FOR WINDOW-CLOSE OF CURRENT-WINDOW. 

The following screen shows both ways that the comments field is handled in this example:

One use for the HOME and END events might be to force the results list to be built in a particular direction when working with INDEXED–REPOSITION queries.

The SCROLL–NOTIFY event is important if you plan to overlay other widgets on browse cells. SCROLL–NOTIFY gives you the ability to move the overlay widget to keep pace with the user’s scrolling. See the "Overlaying Widgets on Browse Cells" section later in this chapter for more information on this technique.

Row Events

The browse supports three row-specific events:

You can find examples of how ROW–ENTRY and ROW–LEAVE work in the "Updating Browse Rows" and "Creating Browse Rows" sections later in the chapter.

The ROW–DISPLAY event lets you change color and font attributes of a row or individual cells or to reference field values in the row. On Windows, the ROW–DISPLAY event lets you change the format of a browse-cell (by changing the value of its FORMAT attribute). The ROW–DISPLAY event cannot be used for any other purpose.

For example, you might want color overdue accounts in red. This kind of cell manipulation is only valid while the cell is in the viewport. For this reason, you need to use ROW–DISPLAY to check each new row as it scrolls into the viewport. The code fragment below shows a sample trigger:

ON ROW-DISPLAY OF b1 
DO: 
    IF balance > credit-limit THEN 
        ASSIGN balance:BGCOLOR IN BROWSE browse1 = white-color 
               balance:FGCOLOR IN BROWSE browse1 = red-color. 
END. 

NOTES:

Column Events

The LEAVE and ENTRY events reference the entire browse widget. For example:

ON ENTRY OF b1 DO: 

You can also write triggers for column names. You can use these triggers to change an attribute of the entire column (change a column background color), or to modify a single cell in that column. The affected cell is the named column in the focused row. For example:

ON LEAVE OF customer.credit-limit IN BROWSE b1 DO: 
    SELF:FONT = bold-font. 
END. 

There are also two events that allow you to interact with search mode. START–SEARCH occurs when the user chooses a column label. END–SEARCH occurs when the user enters edit mode on a cell or selects a row. See the "Searching Columns (Windows Only)" section earlier in this chapter for more information on these events. Note that both of these events can be applied to columns to force the start and end of search mode.


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095