Triggers in Dynamic Browse Class

KingCubicle

New Member
Hi everyone, I'm trying to build a dynamic browse class that accepts a dynamic temp table, query for said table and some parameters for screen location and size. I've hit a bit of a road block getting browse triggers to fire. Basically, I have the code below implemented, and cannot get any events to fire. I have to be doing something wrong. I haven't been able to find very many examples of classes generating dynamic UI components and their triggers.

Here's the constructor....

Code:
CONSTRUCTOR DyBrowse(INPUT dyTThan AS HANDLE  , INPUT cQueryText AS CHAR, INPUT FrameHandle  AS HANDLE, 
                       INPUT dColumn AS DECIMAL , INPUT dRow AS DECIMAL   , INPUT dBrowseWidth AS DECIMAL, INPUT dBrowseHeight AS DECIMAL):
    ASSIGN THIS-OBJECT:dyTThan      = dyTThan
           THIS-OBJECT:cQueryText   = cQueryText
           THIS-OBJECT:FrameHandle  = FrameHandle
           THIS-OBJECT:hBuffer      = dyTThan:DEFAULT-BUFFER-HANDLE
           THIS-OBJECT:dColumn      = dColumn            
           THIS-OBJECT:dRow         = dRow        
           THIS-OBJECT:dBrowseWidth = dBrowseWidth 
           THIS-OBJECT:dBrowseHeight= dBrowseHeight.

    setUpQuery().
    setUpBrowse().
  END CONSTRUCTOR.

And the methods...

Code:
  METHOD PRIVATE VOID setUpQuery():
	create handle, set-buffers, query-prepare, query-open, get-first, etc.
  END METHOD.

  METHOD PRIVATE VOID setUpBrowse():
    create browse BrowseHandle
    assign 
           ROW-MARKERS            = FALSE
           frame                  = FrameHandle
           query                  = QueryHandle
           ROW                    = dRow
           COLUMN                 = dColumn
           WIDTH                  = dBrowseWidth
           HEIGHT                 = dBrowseHeight
           separators             = yes
           multiple               = yes
           visible                = yes
           sensitive              = TRUE
           read-only              = YES
           max-data-guess         = 25
           COLUMN-RESIZABLE       = FALSE
           COLUMN-SCROLLING       = TRUE
           COLUMN-RESIZABLE       = TRUE
           ALLOW-COLUMN-SEARCHING = TRUE
           SCROLLBAR-VERTICAL     = TRUE
           FIT-LAST-COLUMN        = TRUE
      TRIGGERS:
	/* I know this isn't the right place for this, where should i put it? */
        ON 'MOUSE-SELECT-DOWN' MESSAGE 'OK' VIEW-AS ALERT-BOX.
      END TRIGGERS.
  END METHOD.


I found Parul's response here, and tried to implement it to no avail. I can get 'MOUSE-SELECT-DOWN' to fire when I attach it to BrowseHandle from outside the class (there's also a method I didn't list that returns the browse handle), but I can't get the trigger I really want to fire - START-SEARCH - to go.

And while we're at it, speaking of what I want to fire on 'START-SEARCH', BrowseHandle:CURRENT-COLUMN always returns the unknown value (?). Like I mentioned, I used the method Parul suggested to get the trigger (and in turn, the method below) to fire. Does anyone have any idea why that would be?

Code:
METHOD PUBLIC VOID mpSortColumn():
  DO WITH FRAME FrameHandle:
	IF VALID-HANDLE(BrowseHandle:CURRENT-COLUMN)
		MESSAGE 'YAY' VIEW-AS ALERT-BOX.
	ELSE
		MESSAGE 'OH NO' VIEW-AS ALERT-BOX.
  END.
END METHOD.

Thanks in advance everyone!!
 
the trigger only last as long as the procedure that define it is in scope, in your case once the setUpBrowse method ends the trigger is gone... your only option is to use persistent triggers, as we can't attach methods to triggers just yet you'll need a helper procedure to be run persistent.

<pseudo-code>
Code:
-- helper procedure, evtHelper --
input param browseObj as DyBrowse.

procedure onEvent (evtName as character):
  browseObj:onEvent(evtName).
end procedure.

Code:
-- dyn browse --
method createBrowse:
run evtHelper persistent set hEvt (this-object).

create browse
    ...
    triggers:
        on 'eventName' persistent run onEvent in hEvt ('eventName').
        ...
    end.
end method.

method onEvent (eventName as character):
    /* handle trigger loogic */
end method.
 
Thanks for the reply, Medu. I did pretty much exactly what you said, and now I can get my triggers to fire without any problems.

Also, I figured out what my issue was for part #2 of my question - it seems that CURRENT-COLUMN only comes back with a useful value when it's used in the context of START-SEARCH (and possibly other triggers... but seemingly not 'MOUSE-SELECT-DOWN').
 
Back
Top