Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How Validate All EIP Fields on FocusLoss?

EditInPlace

How Validate All EIP Fields on FocusLoss?

by  Gaudalier  Posted    (Edited  )
Hello, again, hello!!!!

Something That You Already Know about the EIP:

1. When a Browse Uses EIP for Edit Record, it use the [color red]EIP MANAGER[/color], So if you Check in the Embeds, you'll find at [Color Blue]Local Objects ->ABC Objects[/color] a new brach that goes by the name of [Color Red]EIP Manager for Browse using ?List(BrowseEIPManager)[/color]. This EIP Manager will do everything concerning to track the EIP for our Browse, altrough as a generic way....

2. So What's to do when you need to do something diferent with an especific EIP's field? You go and ADD your field in [color RED] COLUMN ESPECIFIC [/color] and then you can disable or over-ride something on that field. Again, if you go to the Embeds [Color Blue]Local Objects ->ABC Objects[/color] you'll find your just added field's branch: [Color Red]EIP Field Manager for Browse using ?List for field [color blue]"SOME:FIELD"[/color](EditEntryClass)[/color]. Into this Branch, there is another sub-branch [color red]TakeEvent PROCEDURE(Unsigned Event),BYTE,VIRTUAL[/color] Where is the place we track the field's behavior.

An Example????
Our Account System manages too many customer's credit balances: Payment & loans. So there is a browse in wich we select or type the Customer's code, and we can introduce in either fields, Payments or Loans, any amount. We wanna Call a SelectWindows when the User dobleClik on the CustomerCode field to select it from a Select Windows. Plus not Allowing to change the Customer's Code ONCE it was save AND changing the default backgrond color to Yellow as a matter of Visual sing.

First we add an alert to the field's dobleclick this way (our field's name: CUSAC:CustomerCode):

Local Objects ->ABC Objects ->EIP Field Manager for Browse using ?List for field CUSAC:CustomerCode EditEntryClass) ->SetAlerts PROCEDURE,VIRTUAL

CODE at priority 7500 [color blue]*[/color]
[color Brown]
Code:
SELF.Feq{PROP:Alrt,255} = Mouseleft2 !DobleClick alert
[/color]
-See Clarion's Help for PROP:Alrt,255

and into our belove brach ->TakeEvent PROCEDURE(Unsigned Event),BYTE,VIRTUAL

CODE at priority 2500 [color blue]**[/color]
[color brown]
Code:
CASE EVENT()
  OF EVENT:SELECTED
    IF BRW1.Q.CUSAC:CustomerCode <> '
      Self.Feq{PROP:COLOR,1} = 0D1FEFCH
      Self.Feq{PROP:COLOR,2} = 0
      Self.Feq{PROP:COLOR,3} = 0D1FEFCH
      Self.Feq{PROP:SelStart} = 1 
      Self.Feq{PROP:ReadOnly} = 1
    ELSE
      Self.Feq{PROP:SelStart} = 1 
      Self.Feq{PROP:ReadOnly} = 0
    END 

    Self.Feq{PROP:REQ} = TRUE
    Self.Feq{PROP:IMM} = TRUE
    UPDATE(SELF.FEq)
  OF EVENT:ALERTKEY
      CASE KEYCODE()
        OF MouseLeft2
          GlobalRequest = SelectRecord
          BrwCustomerWindow          
          IF GlobalResponse = RequestCompleted
           BRW1.Q.CUSAC:CustomerCode=CUS:CustomerCode  
           DISPLAY
           RETURN(EditAction:Forward)
          ELSE
            Clear(CUS:Record)
            Display
            Return(EditAction:None)
          END !END IF GlobalResponse = Reques
      END !CASE
[/color]

and again into our belove brach ->TakeEvent PROCEDURE(Unsigned Event),BYTE,VIRTUAL

CODE at priority 7500 [color blue]***[/color]
[color brown]
Code:
UPDATE(SELF.Feq) ! 7500  
IF ReturnValue AND ReturnValue <> EditAction:Cancel AND| EditInPlace::CUSAC:CustomerCode.ReadOnly = 0

  CUS:CustomerCode = BRW1.Q.CUSAC:CustomerCode
  IF Access:Customer.Fetch(CUS:AK_Codigo) = Level:Benign
    BRW1.Q.CUSAC:CustomerCode = CUS:CustomerCode
    DISPLAY
    RETURN(EditAction:Forward)
  ELSE
    GlobalRequest = SelectRecord
    BrwCustomerWindow          
    IF GlobalResponse = RequestCompleted
      BRW1.Q.CUSAC:CustomerCode=CUS:CustomerCode  
      DISPLAY
      RETURN(EditAction:Forward)
    ELSE 
      Clear(CUS:Record)
      Display
      Return(EditAction:None)
    END 
  END 
END !END IF ReturnValue..
[/color]

Well, to ordering our requeriments:
A) DobleClick in our EIP CusAc:CustomerCode will do a LookUp/Select. (in case of we dunno the CustomerCode)

B)When Inserting a new record, the EIP CusAc:CustomerCode Will allow us to capture the CustomerCode.

C)Once the record has a valid CustomerCode, and it was saved, Change the CustomerCode will not be ALLOWED And HighLigted with Yellow color wich is a way to tell "You Can't change me".


Explanation of Code:

A)[color blue]*[/color] To manage the DoubleClick Event, we need first to set an ALERT to the EIP Field, as you know, [color brown]SELF.Feq{PROP:Alrt,255} = Mouseleft2[/color] will add an Alert to Mouse DoubleClick on our field, wich can be manage by embed code [color blue]**[/color] When EVENT() = EVENT:ALERTKEY, and KEYCODE() = Mouseleft2. That Code, very simple!.

B) & C)As we can't disable the Field (if ya know it, tell me how), we surely can set the Field's property to READONLY.

Well, the only way to do color (HihtLight when NOT Blank), is by changing the background color when the FIELD IS SELECTED,[color blue]**[/color], When EVENT() = EVENT:SELECTED AND BRW1.Q.CUSAC:CustomerCode <> ', we change the colors:
Self.Feq{PROP:COLOR,1} = 0D1FEFCH, etc. etc.

[color red]AT WHERE THE FOCUS LOSS FITS INTO????[/color]

Well, our Customer's Credit Balance, has a field CUSAC:payment and CUSAC:Loan, wich are EXCLUSIVE, ergo, you can capture either Payment or Loan, but not both.

That problem is why this FAQ is made for: we'll use the event FocusLoos to verify that CUSAC:payment XOR CUSAC:Loan is correct.

But not today...


Well, It's Today ;)

You'll need a BYTE variable, let's name it LOC:AllowFocusLoss to track down the focus loss event and a LONG variable to save the last FEQ using the EIP control: LOC:EIPFEQ

Go to Local Objects ->ABC Objects ->EIP Field Manager for Browse using ?List (BrowseEditManagerClass)->Take FocusLoss PROCEDURE,VIRTUAL

Put thi code at priority 2500

Code:
IF LOC:AllowFocusLoss = FALSE   !NO permitir salir del EIP
    SELECT(LOC:EIPFEQ)
    PRESSKEY(TABKEY)
    RETURN
END

And again into our beloved EIP branch blah.. blah.. for field CUSAC:CustomerCode EditEntryClass) ->TakeEvent PROCEDURE(Unsigned Event),BYTE,VIRTUAL


Code:
LOC:AllowFocusLoss = FALSE
LOC:EIPFEQ = Self.Feq
Update(Self.Feq)
CASE EVENT()
    OF EVENT:Selected
        IF BRW1.Q.CUSAC:CustomerCode <> '
            LOC:AllowFocusLoss = TRUE 
        ELSE
            LOC:AllowFocusLoss = FALSE
        END
    OF EVENT:Accepted
        IF BRW1.Q.CUSAC:CustomerCode <> '
            LOC:AllowFocusLoss = TRUE !Good boy!!!
            RETURN(EditAction:Complete)
        ELSE
            LOC:AllowFocusLoss = FALSE
            BEEP   !You B*st*rd, type down an Custumer code!
            Return(EditAction:None)

        END
END


Of Course ya must select NEVER on "action upon focus loss" in the configure Edit in Place windows.



Best Regards.










Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top