Sign up on the Revelation Software website to have access to the most current content, and to be able to ask questions and get answers from the Revelation community

At 28 MAY 1998 11:17:14AM Oystein Reigem wrote:

I have a window with a key field, some other fields and a button. The key field has an OPTIONS handler that brings up a popup that returns a value to the key field. The problem is that when I afterwards tab out of the key field I don't always get LOSTFOCUS and READ.

Or to be precise: If I use Alt-Down to bring up the popup everything works fine. But if I use the button, which sends an OPTIONS message to the key field, I don't get LOSTFOCUS and READ. What is the real difference between the two cases?

I know of several reasons this scenario could fail, but this case has got me stumped so far. What's confusing is this occurs in a window that used to work fine, and I really cannot remember doing any changes to the window that possibly could have caused the problem. (What has happened in the meantime, however, is that I had to restore my system from an earlier version. I did an AppBackup Backup/Restore to salvage the newest windows and SP's.)

Can something be said from the System Monitor logs below? The one on the left is from the current system, where LOSTFOCUS fails. The one on the right is from an older version, where everything still was OK.

The logs start with me clicking the button. After that I click on a value in the popup, and on the OK button. Finally I tab out of the key field (BIBL_REG.OBJNR).

So far everything is identical. Here I think it is I tab out of the key field. As you can see in the current version I get no LOSTFOCUS.

- Oystein -

Øystein Reigem, Humanities Information Technologies, Harald Haarfagresgt 31, N-5007 Bergen, Norway. Tel: +47 55 58 32 42. Fax: +47 55 58 94 70. E-mail: [email protected]


At 28 MAY 1998 01:44PM Jeff Word wrote:

Part of the difference would be that clicking on the the button triggers the editline lostfocus. Then when the button triggers the OPTIONS event of the editline the lostfocus has already been triggered earlier. You could do this: In the code on the button, after triggering the OPTIONS event, you may want to focus back on the editline and trigger the gotfocus. That way when you tab off you will trigger the lostfocus.

Are you completely confused yet?


At 28 MAY 1998 02:16PM Steve C. wrote:

This is the script I use in my click event for a pushbutton,

I believe doing what you want to do.

DECLARE FUNCTION SEND_EVENT

WINDOW_NAME=CtrlEntID1,'F.'

void=Send_Event(WINDOW_NAME:".CASE_ID","OPTIONS")

void=SET_PROPERTY(WINDOW_NAME:".CASE_ID","FOCUS",1)

RETURN 0


At 29 MAY 1998 06:13AM Oystein Reigem wrote:

Jeff/Steve,

I'm still confused. I do set the focus back to the key field. (I think I do it the proper way too. Don Bakke once told me Set_Property( "SYSTEM", "FOCUS", CtrlName ) is better than Set_Property( CtrlName, "FOCUS", true$ ).)

Well, fortunately it seems that all places I have this problem (I said perhaps it was one window but it's actually ten windows) I can change the way the window works slightly and avoid the problem. I just send a READ event after the popup (if the user really chose a key from the popup). In the affected windows there is really no reason to wait with the READ until the user leaves the key field. (Actually I think most of my users prefer it the new way.)

So this time I was lucky but I still wonder why it happened.

Thanks both for taking an interest!

- Oystein -


At 29 MAY 1998 09:02AM Don Bakke wrote:

Oystein,

I think the problem has to do with the fact that the GOTFOCUS_VALUE property of the editline (i.e. key field) matches the value of the TEXT property and therefore no READ event is triggered. This, however, is the way it should work or otherwise every time you entered and exited the key field, assuming there were no changes made, the form would attempt to read the record again and again.

I'm not sure why LOSTFOCUS isn't getting triggered nor am I sure why in the past you didn't have any problems.

[email protected]

SRP Computer Solutions


At 01 JUN 1998 10:09AM Cameron Revelation wrote:

Oystein,

Please post the code you are using to launch the Popup.

Cameron Purdy

[email protected]


At 02 JUN 1998 04:58AM Oystein Reigem wrote:

Cameron,

Right. (You asked for it .)

Here is a description from when I had problems: (As I said in a different posting in this thread I have now circumvented the problem and even come up with a better solution.)

The windows in question are data entry windows for table OBJEKT. In that table information about various types of museums objects are stored, e.g photos and artefacts. The various types of objects share a lot of fields, but not all fields. Because of the differences each object type has its own data entry window(s).

The key field of OBJEKT is OBJNR (a VARCHAR). The keys for the latest records written are logged in a table OBJNR_LOGG, along with object type and user id. Sometimes during data entry the user wants to go back to consult or change one the most recent records he saved. One of the purposes of the log is to store the information necessary for that. So I have made a SP SISTE_OBJNR_POPUP that looks in the log and displays in a popup the last few keys for the current object type this particular user saved. The SP is run from an OPTIONS Quickevent. Parameters: 'OBJNR','Foto',. Return value in: @SELF TEXT. So after the quickevent is run the selected key value is in the key field but no READ has been done yet. The READ is supposed to happen when the user leaves the key field. Since I have a button to trigger the key field OPTIONS event, the SP sets focus back to the key field before it finishes. (The SP isn't as lean as it could have been because it can also be used for any other field (ColName) than the key field. The SP then is run so it brings up a two-column popup that shows the most recently saved values of the current field - in addition to the key. The user can select a value and get it copied into the current field. This is useful because very often the user registers series of similar objects, where the value of fields are the same as for (one of) the previous row(s). When used for this purpose the SP can also handle multivalued fields, and it's not run as a quickevent but called from a different SP.) Here is the SP with comments on the main points: <code> function Siste_ObjNr_Popup( SelveCtrlNameEtc, ObjType, ColName, Val ) equate true$ to 1 equate false$ to 0 $INSERT POPUP_EQUATES declare function Farge declare function Set_Property declare function Get_Property declare function POPUP declare function UTILITY /* la cursor være timeglass til rutinen er ferdig */ UtRetVal=UTILITY( 'CURSOR', 'H' ) if not(assigned(Val)) then Val=' if Val=' then Val=true$ /* init returverdi i tilfelle rutinen må gi opp underveis */ ValgtNokkel=' ValgtValNr =' /* navn på control */ CtrlName=@Window : '.' : SelveCtrlNameEtc Bruker=@USERNAME MainTableName=OBJEKT" LoggTableName=OBJNR_LOGG" open LoggTableName to LoggTableVar else call msg( @Window, "Klarar ikkje å opna " : LoggTableName ) goto Slutt end </code> Read from log table: <code> /* les posten for denne brukeren og den aktuelle objekttypen i tabell OBJNR_LOGG */ Key=Bruker : '@' : ObjType read Row from LoggTableVar, Key then /* det var en post */ transfer Row to Oppl end else /* det var ingen post */ Oppl=' end /* finn ut hvor mange registreringer det er i loggen */ AntRegLogg=count( Oppl, @FM ) + (Oppl )

/* åpne OBJEKT, for vi trenger litt mer data å vise enn bare inv.nr.
   og vi vil også sørge for at vi ikke viser registreringer som er slettet */
open MainTableName to MainTableVar else
  call msg( @Window, "Klarar ikkje å opna " : MainTableName )
  return 0
end

/* plukk ut data til popup */
Tell=0
ObjNrListe ='
OppTidListe='
for R=1 to AntRegLogg
  ObjNr =Oppl
  OppTid=Oppl
  /* unngå poster som er slettet */
  if RowExists( MainTableName, ObjNr ) then
    Tell += 1
    ObjNrListe =ObjNr
    OppTidListe=OppTid
  end
next R

if ObjNrListe  "" then
  
  /* vis evt resultat */
  
  /* få tak i obj.type for disse */
  ObjTypeListe=XLATE( MainTableName, ObjNrListe, "OBJTYPE", "X" )

  /* få evt tak i verdi som skal vises */
  if ColName  '' then
    ColValueList=XLATE( MainTableName, ObjNrListe, ColName, "X" )
  end else
    ColValueList='
  end

  /* flett listene (til en @VM-delimited liste) */
  Ant=count( ObjNrListe, @FM ) + (ObjNrListe  '')
  LiteralText='
  for I=1 to Ant  
    /* se opp for mv */
    AntVals=count( ColValueList[i], @VM ) + (ColValueList[i]  '')
    if AntVals=0 then
      /* (selv om feltet er tomt, vil vi at posten skal vise i popup'en) */
      LiteralText     := ObjNrListe[i] : @SVM : '' : @SVM : ObjTypeListe[i] : @SVM : OppTidListe[i] : @SVM : ''                 : @VM
    end else
      for V=1 to AntVals
        LiteralText := ObjNrListe[i] : @SVM : V  : @SVM : ObjTypeListe[i] : @SVM : OppTidListe[i] : @SVM : ColValueList : @VM
      next V
    end
  next I  
  if LiteralText  '' then LiteralText-1, 1='   /* stripp siste @FM */
  /* nøkkel */
  Field   =1
  Width   =13
  TextJust=L"
  HeadJust=L"
  OutConv ="
  Heading =Inv.nr"
  DisplayFormat1=Field : @SVM : Width : @SVM : TextJust : @SVM : HeadJust : @SVM : OutConv : @SVM : Heading
  /* skjult felt for nr på value - hvis mv. ellers blank */
  Field   =2
  Width   =0
  TextJust=L"
  HeadJust=L"
  OutConv ="
  Heading ="
  DisplayFormat2=Field : @SVM : Width : @SVM : TextJust : @SVM : HeadJust : @SVM : OutConv : @SVM : Heading
  /* obj.type */
  Field   =3
  Width   =5
  TextJust=L"
  HeadJust=L"
  OutConv ="
  Heading =Type"
  DisplayFormat3=Field : @SVM : Width : @SVM : TextJust : @SVM : HeadJust : @SVM : OutConv : @SVM : Heading
  /* tidspunkt */
  Field   =4
  Width   =16
  TextJust=L"
  HeadJust=L"
  OutConv ="
  Heading =Lagra/Oppdatert"
  DisplayFormat4=Field : @SVM : Width : @SVM : TextJust : @SVM : HeadJust : @SVM : OutConv : @SVM : Heading
  /* felt */
  if ColName  '' then
    Field   =5
    Width   =38
    TextJust=L"
    HeadJust=L"
    OutConv ="
    Heading ="
    DisplayFormat5=Field : @SVM : Width : @SVM : TextJust : @SVM : HeadJust : @SVM : OutConv : @SVM : Heading
  end
  TypeOverride="
  TypeOverride=Farge(255:@FM:255:@FM:128)
  TypeOverride   =L'
  TypeOverride   =E'
  TypeOverride =DisplayFormat1 : @VM : DisplayFormat2 : @VM : DisplayFormat3 : @VM : DisplayFormat4 
  if ColName  '' then
    TypeOverride=TypeOverride : @VM : DisplayFormat5
  end 
  TypeOverride=LiteralText  
  TypeOverride  =Dei siste lagra/endra inv.nr"

</code>

Display the popup:

    RetPopupRow=POPUP( @Window, TypeOverride )
    if RetPopupRow  '' then
      ValgtNokkel=RetPopupRow   /* The selected key */
      ValgtValNr =RetPopupRow   /* For normal fields (not key fields) that are multivalued: The number of the value */
    end else
      ValgtNokkel=' 
      ValgtValNr ='
    end
    
  end else
  
    if AntRegLogg ] 0 then
      call msg( @Window, 'Loggen med dei siste postane inneheld berre sletta registreringar' )
    end else
      call msg( @Window, 'Loggen med dei siste postane er tom' )
    end
    ValgtNokkel='
    ValgtValNr ='
      
  end

Set focus back to the key field:

Slutt:
      
  /* sett fokus til inv.nr-feltet (i tilfelle rutinen er kjørt ved å trykke en knapp) */
  OldVal=Set_Property( "SYSTEM", "FOCUS", CtrlName )
      
  /* sett cursor til pil igjen */
  UtRetVal=UTILITY( 'CURSOR', 'A' )
  

I know the "if" case of this "if" sentence looks dodgy with its @FM but it's the "else" case that is executed in my case. (And in the "if" case the context is quite different. The return value is not put into a field):

  if Val and (ValgtValNr  '') then
    return ValgtNokkel : @FM : ValgtValNr
  end else
    return ValgtNokkel
  end

- Oystein -

Øystein Reigem, Humanities Information Technologies, Harald Haarfagresgt 31, N-5007 Bergen, Norway. Tel: +47 55 58 32 42. Fax: +47 55 58 94 70. E-mail: [email protected]


At 02 JUN 1998 05:03AM Oystein Reigem wrote:

Don,

I think the problem has to do with the fact that the GOTFOCUS_VALUE property of the editline (i.e. key field) matches the value of the TEXT property and therefore no READ event is triggered.

Normally the key field is empty when the user presses the key that brings up the popup (via the key field OPTIONS event). So it cannot be what you suggest. But can the system for some reason still believe no change has been done. (Should I have used DEFPROP instead???)

I'm not sure why LOSTFOCUS isn't getting triggered nor am I sure why in the past you didn't have any problems.

(Thinking aloud:) What about promoted events? Did I have an experimental promoted LOSTFOCUS event once?

- Oystein -


At 02 JUN 1998 08:33AM Cameron Revelation wrote:

Oystein,

I still can't tell … what order are you doing the following two items in:

1) Set DEFPROP of control

2) Set FOCUS to control

If you do it 1 then 2 it will not work; if you do it 2 then 1 then it will work.

Cameron Purdy

[email protected]


At 02 JUN 1998 09:07AM Don Bakke wrote:

Oystein,

Normally the key field is empty when the user presses the key that brings up the popup (via the key field OPTIONS event). So it cannot be what you suggest. But can the system for some reason still believe no change has been done. (Should I have used DEFPROP instead???)

Wait a second…I thought you said that pressing the key to bring up the PopUp works, but clicking on a button to bring up the PopUp doesn't work. If so, the reason is that in the first scenario the form's FOCUS never leaves the key ID so the GOTFOCUS_VALUE is still null. So when the PopUp returns a value and the user moves to a new field, the form recognizes that the TEXT property is now different from the GOTFOCUS_VALUE of the key ID field and therefore will process the READ event. In the second scenario, the FOCUS leaves the key ID field to go to the button. So when the PopUp returns a value that is used to update the TEXT property of the key ID, and then focus is placed on the key ID field, the GOTFOCUS_VALUE of this field is now the same as the return value of the PopUp. So moving to a new field at this point won't do anything because the GOTFOCUS_VALUE and the TEXT property of the key ID field are identical.

Since you are sending a READ event after the PopUp's return value has already been sent to the key ID, you are fine. However, if you wanted the READ event to be triggered by leaving the key ID field then my suggestion is to add some code to the CLICK event of the button that returns focus to the key ID field first before launching the PopUp. That way the GOTFOCUS_VALUE will be null when you update the TEXT property with the return value of the PopUp and a READ event should occur naturally when moving to another field.

I don't recommend using the DEFPROP because in the situation where you programmatically send a READ event you will always get the SAVEWARN message since DEFPROP registers a change in the form's data…even if it is just the key ID being changed.

[email protected]

SRP Computer Solutions


At 03 JUN 1998 04:33AM Oystein Reigem wrote:

Cameron,

I did it in the wrong order. But why exactly is it wrong? (Never mind!)

- Oystein -


At 03 JUN 1998 04:45AM Oystein Reigem wrote:

Don,

Was it really that simple? How embarrassing!

- Oystein -

View this thread on the forum...

  • third_party_content/community/commentary/forums_nonworks/783fd618cc233211852566120053f9ec.txt
  • Last modified: 2024/01/04 21:00
  • by 127.0.0.1