Uniface User Forum

 View Only
Expand all | Collapse all

Check on FRLF and depending on answer saty or leave form ...

  • 1.  Check on FRLF and depending on answer saty or leave form ...

    Posted 04-09-2024 10:38

    Hi Freaks

    My challenge:
    In a non modal world I have to check on FormLoseFocus some conditions and  ask the user how to proceed.
    I.e stay in the instance or leave it to the clicked one. 
    Under certain circumstances, data is also stored

    As mentioned in the documentation, in a FRLF trigger the allowed statments  are limited, especialy a ask-message should not be presented to the user
    So my idea is to send a message to the current(old) instance (and return with -1) which calls the ASYNC-trigger. In this I can call check routines and ask the user,
    But now I run into a problem:
    If the user say leave the current instance and go to the clicked (new) instance, which instance is this?

    Question:
    Is there any way to get (in FRLF) the instance,  which should get the focus next?


    BTW:
    For the good old version 9.7  I did a comlpex ping-pong coding to get such information and handle checks and stores on FRLF
    But with 10,4 the sequnce was changed and I did not find a way to implement our needs ...

    Ingo



    ------------------------------
    Ingo Stiller
    Aareon Deutschland GmbH
    ------------------------------


  • 2.  RE: Check on FRLF and depending on answer saty or leave form ...

    Posted 04-10-2024 03:40

    Hi Ingo,

    small thinking about your challenge...

    1) Suggestion: Could you anticipate your front-end issue (no direct askmess in FRLF!) in the button user clicks desiring to go to another form? Could you ask to user what to do in the button code?

    2) Tip: FRLF is not friendly with some proc instructions but you could always put those instructions in an entry (local or global) and call the entry from FRLF... right? It is just need your code gracefully end without badly interfering with FRLF itself.



    ------------------------------
    Gianni Sandigliano
    IT
    ------------------------------



  • 3.  RE: Check on FRLF and depending on answer saty or leave form ...

    Posted 04-10-2024 04:23

    ad 1) Nop, not feasible. We do have a very dynamic master-detail-"desktop" . And the user can click anywhere he/she want's to go :-)
    ad 2) I do call already hundreds of (globale) procedures from FRGF/FRLF. And in UF9 all did work quite nice, but in UF10, I run into a problem.

    As there is no $nextinstance() (or UnifAce?) I have to code a Ping-Pong-game
    A.FRLF -> postmessage to a unknown*)  instance.
    B.FRGF -> If I receive such message, send back a message to instance A with the now known Intancename B
    A.ASYNC->Get the message, do the FRLF-checks and then stay or leave A again. 

    And the next challenge is to trigger the Store-trigger in A.
    As it looks like, this can only be done by macro "^store".
    But this in turn is again async, so I have to send a message from A to A to check the result of 'store'


    Let's hope that Uniface will let play me this game :-)

    *) As this is not possible, I have to use globalen variables witch holds "messages"
        In this in tuen is also a problem, as we do have two libraries in use and I don't not know which of those both are used by B
        So , use good old $nn-variables



    ------------------------------
    Ingo Stiller
    Aareon Deutschland GmbH
    ------------------------------



  • 4.  RE: Check on FRLF and depending on answer saty or leave form ...

    Posted 04-10-2024 05:06

    Gianni's tip 2 suggestion is the way it is working.... where I am...

    I would be interested to know what problems you found... and maybe there are solutions to them.

    My basic thought is: It should not be to difficult to ask 'are you sure' if you leave a form



    ------------------------------
    Osman Shariff
    ------------------------------



  • 5.  RE: Check on FRLF and depending on answer saty or leave form ...

    Posted 04-10-2024 05:32
    Hi Osman
    I can't ask the user :-)
    Do not change focus using the loseFocus trigger. For example, you should not use ProcScript instructions such assetformfocusor$prompt, display a dialog box, or activate another component instance in this trigger
    The proposed solution is
    postmessage $instancename, "DialogShow", "FLD1 must have a value"

    But doing so
    1) The only instance I know on FRLF is the current one, not the next one
    2) When I got the message in ASYNC, I can display a message but there is no way to jump to the next instance, as  I don't know it

    Ingo


    ------------------------------
    Ingo Stiller
    Aareon Deutschland GmbH
    ------------------------------



  • 6.  RE: Check on FRLF and depending on answer saty or leave form ...

    Posted 04-10-2024 09:57

    Hi Ingo

    I saw that and saw we got an askmess in a global proc, in the frm losefocus trigger.  It seems to work fine for us...

    I had a look, but as you say, you cant know what was clicked until after the losefocus trigger is fired

    Maybe the pingpong might work with $instanceparent, $instancechildren.... dunno...  



    ------------------------------
    Osman Shariff
    ------------------------------



  • 7.  RE: Check on FRLF and depending on answer saty or leave form ...

    PARTNER
    Posted 04-10-2024 10:59

    maybe instead let the focus go to the new component, then detect there you came from the old component and refocus it, now you know both instances?



    ------------------------------
    Neil Payne
    MRI Occupier LLC
    London GB
    ------------------------------



  • 8.  RE: Check on FRLF and depending on answer saty or leave form ...

    Posted 04-11-2024 03:22

    That's what I try to code now: a Ping-Pong-game between the two involved instances :-)

    Problem challenge is, for a user this should look like he/she could jump everywhere and the jump-target ( after a possible query)  is still the same.

    @UnifAce: you do have the information of the jump target (instance,entity, field) already in the memory, why not present it to us by a (few) simple function(s)?
    $TargetInstance()
    $TargetEntityname()
    $TargetFieldname()



    ------------------------------
    Ingo Stiller
    Aareon Deutschland GmbH
    ------------------------------



  • 9.  RE: Check on FRLF and depending on answer saty or leave form ...

    ROCKETEER
    Posted 04-11-2024 12:08

    It may be possible to return 0 out of the loseFocus trigger and use postmessage.

    trigger receiveMessage
      throws
      variables
        string vInstance
      endvariables
      selectcase $uppercase($result)
      case "MESSAGE"
        selectcase $uppercase($msgid)
        case "FOCUS1"
          vInstance = $formfocus ; Remember the form that has the focus
          setformfocus $instancename ; Set the focus back to this form
          postmessage $instancename, "FOCUS2", vInstance ;  a postmessage here will allow this form to get focus
        case "FOCUS2"
          askmess "Swap focus?"
          if ( $status )
            ; Do store here
            setformfocus $msgdata
          endif
        endselectcase
      endselectcase
    end
    trigger loseFocus
    throws
      if ( !checkValidation() )
        postmessage $componentname, "FOCUS1"
      endif
      return 0
    end
    Kind regards,
    Mike



    ------------------------------
    Michael Taylor
    Rocket Internal - All Brands
    ------------------------------



  • 10.  RE: Check on FRLF and depending on answer saty or leave form ...

    Posted 04-12-2024 03:04

    So, here is my solution for the ping-pong-game :-)
    E00, D00 are the involved instances. DTF is a framework.
    E00, D00, DTF are symbolic component names, at runtime this could be any instance.
    (so a postmessage from D00/FRLF to E00/FRGF is not possible)
    The components could be in different libraries, that's why I can't use a global vaiable as message-stack.
     



    ------------------------------
    Ingo Stiller
    Aareon Deutschland GmbH
    ------------------------------



  • 11.  RE: Check on FRLF and depending on answer saty or leave form ...

    Posted 04-12-2024 10:50

    Hi UnifAce
    The ping-pong-game works.
    But how to activate the STORE-trigger before a postmessage will call the ASYNC?

    Challenge:
     A user can switch focus from E00->D00->E00 (or any other sequence)
     When ever in D00 something was modifed, the user has to be aske if he/she want's to store
     As our store-proccode is in the STORE-trigger, we need to activae the trigger

    This is my (simplified) code

    Component D00/FRLF
       a little bit of ping-pong to get both instancce (FRLF and FRGF)
       postmessage as in a FRGF no askmess is allowed

     postmessage $instancename(),"DO_STORE_UNDER_CONDITION"

    Component D00/ ASYNC
    CASE  "DO_STORE_UNDER_CONDITION"
      aksmess ... 
      macro "^store"
      postmessage $instancename(),"CHK_STORE"
    CASE "CHK_STORE""
      check a few global variables  if or if not the store was okay
      IF (okay)    setfomfocus v_INST_E00

    But doing so, the pendig message will befired first and the the macro.
    So no changes to 'watch' the store

    any idea



    ------------------------------
    Ingo Stiller
    Aareon Deutschland GmbH
    ------------------------------



  • 12.  RE: Check on FRLF and depending on answer saty or leave form ...

    Posted 30 days ago

    So, I hope I do have the final PingPong-Game implemented. Next step is to migrate additional handling on FRLF/STORE into the procedures.
    The game/procedures  looks easy, but there's a bit more going on in the background
    Here is the  simplified  PingPong-Game :-)



    ------------------------------
    Ingo Stiller
    Aareon Deutschland GmbH
    ------------------------------