Home page Home page Home page Home page
Pixel Header R1 C1 Pixel
Pixel Header R2 C1 Pixel
Pixel Header R3 C1 Pixel
By Sprezz | Sunday, 25 December 2011 18:55 | 0 Comments
Following on from our last post on colouring individual popup lines we move onto one of the holy grails of developers - the ability to add a button to a popup and launch our own program from it - interrogating the popup to display more information about the current row for example. Using the example we showed last time - note that we now have a button on the popup called "Display"

Clicking the button results in this

To accomplish this we need to be familiar with

  • The TIMER tecnique we discussed in the last blog posting
  • The fully qualified entity ids of the individual popup controls
  • The use of Window Common
  • The structure of the Window Common used for quick events

The TIMER technique we discussed in the last blog posting
If you haven't yet read the last blog entry then you might like to before continuing.

The fully qualified entity ids of the individual popup controls
To add a display buttton to the popup we could add a new control to the popup on the fly but that is a lot more complicated than taking over a control that already exists. So the trick that we are going to use is to add a button on to the popup that we're not going to use for its stated purpose and change its display text to "Display" and its action to something more suited to our use.

For this example I'm going to hijack the "Print" button so we need to add that to the popup definition.

For your purposes you might want to use one of the other controls so for your convenience here's a list of them all :-


Returning to our timer event - the first thing that we're going to do is to modify the TEXT of the print button to make it read "Display".

printButton = "POPUP.CB_PRINT"

objxArray := @Rm : printButton
propArray := @Rm : "TEXT" 
dataArray := @Rm : "Display"       

dataArray = set_Property( objxArray, propArray, dataArray ) 

With that done we need to go about modifying the action to take on the click.

The use of Window Common
To use Window Common you just have to add the following code to your subroutine.

   winId = "POPUP"
   $Insert oiwin_Comm_Init

If you're not familiar with Window Common then where've you been for the past 15 years?

The structure of the Window Common used for quick events
Window Common was effectively documented in detail in Technical Bulletin #2 - Compiled Window Structures, available on an old Works CD. We only need a very limited subset however so we'll deal with that.

Each control on the window has the events associated with it in the variable controlSemantics@. So we need to firstly find the control, then find the CLICK event associated with it and then remove the logic that is currently there and replace it with a call to OUR routine instead.

The quickevent structure that we need is as follows :-

quickEventInfo<0, 0, 0, 1 >  =  Code for type of event
quickEventInfo<0, 0, 0, 2 >  =  The action to take
quickEventInfo<0, 0, 0, 3>  :=  The routine to call
quickEventInfo<0, 0, 0, 4>   =  The parameters to pass

So when the popup is originally launched the labelled common looks like this

We want to modify it to look like this

The code required to do this is as follows :-

Locate printButton In controlMap@ using @fm setting gotIt then

      OK let's change the quickevent to call OUR program passing in the usual

   quickEventInfo  = "R" : @Tm    
   quickEventInfo := "EXECUTE" : @Tm    
   quickEventInfo := @appId<1> : "*STPROCEXE**" : atSelf : @Tm    
   quickEventInfo := "@SELF" : @stm : "@EVENT" : @stm : "@PARAM1" : |
                     @stm : "@PARAM2" : @stm : "@PARAM3" : @stm : |
                     "@PARAM4" : @stm : "@PARAM5" : @stm : "@PARAM6" : @tm    
   quickEventInfo := @tm              

   Locate "CLICK" In controlSemantics@< gotIt, 8 > using @svm setting gotClick then
      controlSemantics@< gotIt, 9, gotClick > = quickEventInfo                 


So now all we need to do is to take whatever action we want in our commuter program when the CLICK event is triggered. Here's the code from earlier in this blog post.


   begin case
      case object = "POPUP.CB_PRINT"
         objxArray = "POPUP.ET_POPUP"
         propArray = "LIST"
         objxArray := @Rm : "POPUP.ET_POPUP"
         propArray := @Rm : "SELPOS"
         dataArray = get_Property( objxArray, propArray )
         list = dataArray[1, @Rm]
         selPos = dataArray[col2()+1, @Rm]
         call Msg(@window, "Your cursor is on " : list< selPos<2>, 1>)
   end case


Hopefully this will give you ideas of your own to extend the power and flexibility of popups.


Post a Comment

Subscribe to Post Comments [Atom]

<< Home

Pixel Footer R1 C1 Pixel