If ThisWindow.Run(1,ChangeRecord) = RequestCompleted
IF BRW4::NoScrollDown
BRW4::NoScrollDown = False
ELSIF KEYCODE() <> MouseRight
POST(EVENT:ScrollDown,?ListCostItems)
END
End
The code does what I want in that the update form is called and the browse row moves to the next record. However, if I try to press the alert key again, the alert key event does not fire. I have to manually click on the browse to get the alert key event to fire.
I’m guessing perhaps there’s a browse reset or window method I need to call.
I’ve Tried SELECT(?ListCostItems,Choice(?ListCostItems)), after EVENT:ScrollDown, to no avail.
Basically, my client wants to iterate through the browse one row at a time with the ability to Alert(F2Key) along the way with F2 calling the update form.
I suspect you’re missing something - some detail you’ve overlooked. If the key is Alerted at the window level, then you’ll get the Event at the window level when the key is pressed. I suggest you chase that a bit to see who is “swallowing” it (likely via an Event:PreAlertKey)
Rather than calling ThisWindow.Run(1,ChangeRecord) in the Alert Key Event I would try to run the Change button code so all the Browse refresh happens as normal. You just need a Local variable Flag. I’ll take some of Purple Edge’s code.
In the embed for the Alert Key Event:
IF KEYCODE() = F2Key |
AND ~?ChangeButton{PROP:Disable} THEN !if no records its Disabled
MoveDownF2 = True
POST(Event:Accepted,?ChangeButton)
END
In the Embed for the Change button after the Update check if the F2 Move Down flag is True and do your code. This way .Update() runs all the Browse Refresh code:
OF ?ChangeButton
ThisWindow.Update() !<--- Generated
! [Priority 8500]
IF MoveDownF2 = True THEN
MoveDownF2 = False
... your code to move down ...
END
This will always Move Down even if the user cancels. I think that’s ok. If you want to prevent that then at the end of ThisWindow.Run() check for Cancel:
IF Request = 2 AND ReturnValue <> RequestCompleted
MoveDownF2 = False
END
Another approach to consider is instead of using an Alert Key set the attribute KEY(F2Key) on the Change button. That will make F2 press the Change button where you can check for F2
OF ?ChangeButton
IF KEYCODE()=F2Key THEN MoveDownF2 = True.
ThisWindow.Update() !<--- Generated
! [Priority 8500]
IF MoveDownF2 = True THEN
MoveDownF2 = False
... your code to move down ...
END