Sorry for the noob question. I'll do my best asking this.

Sorry for the noob question. I'll do my best asking this.

How the best way to return the focus to the visual component responsible for a data field that raise an exception in data validation?

I made a detailed example of what I mean by that:
https://gist.github.com/dipold/7c75821fba7a10ec1dad6620b8fcd141

Comments

  1. No .. my question is not related to the SetFocus command itself .. sorry if I can not be more understandable ...

    ReplyDelete
  2. Ah, after looking over your code I see what you're getting at.  I posted a suggestion about how to deal with it.

    The power of exceptions is that you don't need to know or care about exactly where or how they'll be handled.  But if you know that the thing that will handle the problem is the immediate caller of the current function, you don't need to use exceptions, and it's a lot simpler to just have a simple way of passing back a result that the caller will understand.

    ReplyDelete
  3. Thanks, I like that, but this way has the disadvantage of requires an undesirable coupling between the entity unit and the form unit, right?

    ReplyDelete
  4. Rafael Dipold Good point.  On the other hand, something has to be coupled somewhere.  The trick is to figure out the right point at which to couple things.

    If the data type isn't declared in the same unit as the form that edits it, (which wasn't clear from your snippet,) then that specific suggestion is probably not the best way to handle it.  But it's a start.

    ReplyDelete
  5. I posted a Mediator Pattern that handles dependencies...

    ReplyDelete
  6. Very interesting.. I will search more about

    ReplyDelete

Post a Comment