NetTalk Central

Author Topic: Focus after lookup field  (Read 4813 times)

hkalmbach

  • Jr. Member
  • **
  • Posts: 81
    • View Profile
    • Email
Focus after lookup field
« on: February 27, 2019, 10:14:14 AM »
Hi,

I have a simple form with 3 entry fields and some display fields. The first field is a string lookup field. Its possible to do manual entries, which then are looked up in a table.
In the string field I set the focus to the second field (when accepted set focus on...).
In the embed point 'Add Server Code Here' I read and set some values for display fields. For them the I do a validate::value and a refresh to show the new values after the lookup.

  ERS:EANCode = SUB(EANCode,1,12)
  GET(Ersatzteile,ERS:KeyEANCode)
  ErsBezeichnung = CLIP(ERS:Nummer) & ' ' & ERS:Bezeichnung
  ErsSysPk = ERS:SysPk
  Menge = 1
 
  ERL:ErsSysPk = ErsSysPk
  SET(ERL:KeyErsSysPk,ERL:KeyErsSysPk)
  NEXT(Ersatzlager)
  IF ~ERRORCODE() THEN
    Lagerort = ERL:Lagerort
    p_web.SSV('Lagerort',Lagerort)
  END 
 
  p_web.SSV('ErsSysPk',ErsSysPk)
  p_web.SSV('LaoErsSysPk',ErsSysPk)
  p_web.SSV('ErsBezeichnung',ErsBezeichnung)
  p_web.SSV('Menge',Menge)
 
  DO ValidateValue::Lagerort
  DO Refresh::Lagerort

  DO ValidateValue::Ersbezeichnung
  DO Refresh::ErsBezeichnung

  DO ValidateValue::Menge
  DO Refresh::Menge
 
Everything works, but after the lookup the focus is not set to the second field (Label Menge). None of the to field really has the focus.
If I press tab the focus is to the second field.

What can be wrong here, who can I set the focus to the field Menge?

Thanks for every help.

Cheers
Heinz

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11251
    • View Profile
Re: Focus after lookup field
« Reply #1 on: February 28, 2019, 02:24:05 AM »
Hi Heinz,

I'd need an example to understand what is happening.

cheers
Bruce

hkalmbach

  • Jr. Member
  • **
  • Posts: 81
    • View Profile
    • Email
Re: Focus after lookup field
« Reply #2 on: February 28, 2019, 05:03:38 AM »
Hi Bruce,

you need an exampe as application or a detailed description?

Here is the description. In the attachment you find a picture of the form. Its a form based on memory.

Pressing 'Speichern' the form calls itself again, passing an action parameter which does the action defined in the GenerateForm embed, actions can be 'Save' and 'Empty', 'Save' puts the last entries into the database, 'Empty' clears the form. In this way the form cycles until the user aborts or selects the main menu.

The process is the following. The user opens the form which then is empty. Then he types the number of a spare part or scans a barcode with a scanner as keyboard wedge.
If he accepts the EANCode field then in the source code in the embed ValidateValue loads data from the data base (description and first stock location). The fields 'ErsBezeichnung', 'Menge' and 'Lagerort' are in the reset list of 'EANCode'.

As remarked the focus field is set to 'Menge' (amount).
But the focus is not set to 'Menge', it is somewhere, after pressing 'Tab' it is in 'Menge'.

The code I use:

Validate::EANCode Routine
  data
! Start of "After Validate New Value"
! [Priority 5000]

! End of "After Validate New Value"
  code
  ! Start of "After Validate New Value"
  ! [Priority 5000]
 
  ! End of "After Validate New Value"
  ! Start of "Validate New Value"
  ! [Priority 5000]
 
  ! End of "Validate New Value"
  ! Start of "Validate New Value"
  ! [Priority 5000]
 
  ! End of "Validate New Value"
  If p_web.Ajax = 1 and p_web.ifExistsValue('NewValue')
    EANCode = p_web.GetValue('NewValue')
  ElsIf p_web.IfExistsValue('Value') !FormFieldPicture = '@s20'  !FieldPicture =
    EANCode = p_web.Dformat(p_web.GetValue('Value'),'@s20')
  End
  do ValidateValue::EANCode  ! copies value to session value if valid.
  If loc:noFocus = false
    p_web.SetValue('SelectField',clip(loc:formname) & '.' & p_web.NoColon(Menge))
  End
  ! Start of "After Validate New Value"
  ! [Priority 4000]
 
 
  ! End of "After Validate New Value"

  p_web.PushEvent('parentupdated')
  do Refresh::EANCode   ! Field is auto-validated
  do SendMessage
  do Refresh::ErsBezeichnung  !(GenerateFieldReset)
  do Refresh::Lagerort  !(GenerateFieldReset)
  do Refresh::Menge  !(GenerateFieldReset)
  p_web.ntForm(loc:formname,'ready') ! 8.67 (in case the form was not the originator of the Ajax call)
  ! Start of "After Validate New Value, After sending replies"
  ! [Priority 5000]
 
  ! End of "After Validate New Value, After sending replies"
  p_web.PopEvent()


ValidatValue::EANCode ROUTINE

  ! End of "Validate Value"
      If loc:invalid = '' then p_web.SetSessionValue('EANCode',EANCode).   !NetTalk
  ! Start of "Validate Value"
  ! [Priority 5000]

  IF LEN(CLIP(EANCode)) THEN
    p_web.OpenFile(Ersatzteile)
    p_web.OpenFile(ErsatzLager)
 
    EANCode = LEFT(CLIP(EANCode))
    ERS:EANCode = SUB(EANCode,1,12)
    GET(Ersatzteile,ERS:KeyEANCode)
    IF ERRORCODE() THEN CLEAR(ERS:Record).
    ErsBezeichnung = CLIP(ERS:Nummer) & ' ' & ERS:Bezeichnung
    ErsSysPk = ERS:SysPk
    Menge = 1
   
    Lagerort = ''
    ERL:ErsSysPk = ErsSysPk  !get the first stock location
    SET(ERL:KeyErsSysPk,ERL:KeyErsSysPk)
    NEXT(Ersatzlager)
    IF ~ERRORCODE() THEN
      Lagerort = ERL:Lagerort
    END 
   
    p_web.SSV('ErsSysPk',ErsSysPk)
    p_web.SSV('Lagerort',Lagerort)
    p_web.SSV('ErsBezeichnung',ErsBezeichnung)
    p_web.SSV('Menge',Menge)
   
    p_web.CloseFile(Ersatzteile)
    p_web.CloseFile(ErsatzLager)
   
    p_web.SetValue('SelectField',clip(loc:formname) & '.' & p_web.NoColon(Menge))   !NetTalk
  END     


Some times I can see, that accepting 'EANCode' the cursor jumps to 'Menge', but then refreshing or reseting the other fields appears afterwards and after that the focus is no longer in an input field.

I hope this explans the facts.

If its not enough please tell me what to send you.

Thanks a lot

Cheers
Heinz

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11251
    • View Profile
Re: Focus after lookup field
« Reply #3 on: February 28, 2019, 06:45:59 AM »
>> you need an example as application or a detailed description?

both is good, but always an app etc that I can compile.

cheers
Bruce