The issue occurs because you don’t yet fully understand the event flow of the GotFocus, LostFocus, and Valid handlers. It’s important to be clear about the role of each one:
On GotFocus – triggered when the control receives focus.
On LostFocus – triggered when the control loses focus.
Valid – determines whether the control is allowed to lose focus. If it returns .F., the focus stays on that control.
In your specific case:
While you are in TxtCocd, clicking on txtCoNm keeps the focus locked because the Valid event does not allow leaving the control until txtCoNm is filled. This is expected behavior — that’s exactly how the Valid event is designed to work.
It’s also essential to remember that, unlike Clipper, which operated in a sequential flow, MiniGUI is entirely event-driven. This shifts the logic of the application, and you must pay close attention to when each event fires and how one event can trigger another.
There are several ways to handle these validations, but you will only be able to choose the best approach once you truly understand the event model. Personally, I do not recommend placing validations directly on the GET controls, because this often leads to unexpected behavior and makes maintenance more difficult.
Instead, I prefer moving all validations to the Save button, performing a clean and centralized check and setting the focus on the first invalid field:
SaveButton() Local aList := { "A", "B", "C" } FOR i := 1 TO 3 IF Empty( form.&( aList[i] ).Value ) form.&( aList[i] ):SetFocus() Return .F. ENDIF NEXT // ...continues...
With this approach you:
Avoid unnecessary focus locking;
Centralize all validation in one place;
Keep the code clean, simple, and easy to maintain;
Work in full alignment with MiniGUI’s event-driven model.
Finally, I always encourage users to include a minimal reproducible example when asking for help. This avoids forcing others to imagine the entire scenario or guess what external functions might be doing. In many cases, creating a simple test case helps you identify the cause of the issue yourself.
--
Visit our website on https://www.hmgextended.com/ or https://www.hmgextended.org/
---
You received this message because you are subscribed to the Google Groups "Harbour Minigui" group.
To unsubscribe from this group and stop receiving emails from it, send an email to minigui-foru...@googlegroups.com.
To view this discussion, visit https://groups.google.com/d/msgid/minigui-forum/CAPFyMQN%2BBSGLU2-4eWOj-duCN8OkLmmYbCiz_w9yRtoNX1QNZA%40mail.gmail.com.