TechTips: The little gotcha called "doDefault" 
Author Message
 TechTips: The little gotcha called "doDefault"

The "doDefault" statement is particularly important in Paradox for
Windows, especially when used on methods such as "Open."

When anything happens in the world of Paradox, the first order of
business is to look for any methods that you may have attached to any
object in the current chain-of-command ("bubble train").  The first
method found is executed.  (And it usually ends there, unless you get
really funky using "passEvent.")

If no method is found, Paradox executes the default action.  In the case
of many objects that is "nothing at all."  In the case of pushbutton,
it's the visual click of the button.  In the case of "open," it's when
the form actually finishes opening itself.

When your code executes, Paradox has -not- yet executed any "default"
action.  It is executing your code -first.-  

        *  The first execution of "doDefault" will cause the default
                response to happen -now.-  (It will not happen again.)

        *  "DisableDefault" can prevent the default action from
                occurring once your method is through.

        *  If neither triggered nor disabled, the default action will
                occur when your method ends.

Let's look at "open."  (Assume the event -is- directed at the form, not
for one of its children.)  

Until the default action occurs, your form is not "really open yet."  If
you cancel at this point the form will not open at all.  And UNTIL you
say "doDefault," your form is in a bit of limbo.  Trying to refer to
most of its properties, or to things that are supposed to be on it (they
are not opened yet, either...) is a definite no-no.  It can cause all
kinds of fireworks.

So here's a plausible thing you could decide to do in an "open" method:

        (a) First you want to open a library, and quit if you can't.

        (b) Then you want to position the cursor to the "SKU" field
                when the form opens (sure there are other ways to do
                this... it's an example!)

in the relevant part of the form's open method (say...):

        if not ulib.Open(":LB:MYAPP.LSL") then
          disableDefault
          msgStop("Oops", "Can't open library! bye!")
          return
        endif

        DoDefault

        SKU.MoveTo()

The "doDefault" statement ensures that the form is completely open and
initialized before attempting to move the cursor to the control.

------------------------------------------------------------------
Sundial Services :: Scottsdale, AZ (USA) :: (480) 946-8259

Quote:
> Fast(!), automatic table-repair with two clicks of the mouse!
> ChimneySweep(R):  "Click click, it's fixed!" {tm}
> http://www.***.com/



Thu, 10 Apr 2003 03:00:00 GMT
 TechTips: The little gotcha called "doDefault"

That's also a reasonable way to do it, Mike, particularly if you want to
position to the field each time you arrive back at the window.  And once
again I would start that method with "doDefault" to make sure that
Paradox is through with the jet-lag and "has really arrived."

{Gentle reader,} There are specific places where you must -not- call
doDefault, by the way.  The default for an "action" method is, of
course, to perform that action, unless you have set a non-zero error
code against that action.  If you might want to block the action, it is
imperative (a) that you know what the <bleep!> you're doing (with some
actions), and (b) that you block before it fires.

Quote:


> > The "doDefault" statement ensures that the form is completely open and
> > initialized before attempting to move the cursor to the control.

> well, not necessarily. To be absolutely sure that everything's finished,
> you should really put the attempt to move the cursor to the control in
> the page::arrive() method. so that it doesn't get moved by some other
> default behaviour after you've moved it yourself.

> --
> Mike Irwin                    It's not because things are hard that we
> [Volunteer CTech Sysop,       don't dare them; it's because we don't
> not a Corel employee]         dare them that they are hard - Seneca.

--
------------------------------------------------------------------
Sundial Services :: Scottsdale, AZ (USA) :: (480) 946-8259

- Show quoted text -

Quote:
> Fast(!), automatic table-repair with two clicks of the mouse!
> ChimneySweep(R):  "Click click, it's fixed!" {tm}
> http://www.sundialservices.com/products/chimneysweep



Thu, 10 Apr 2003 03:00:00 GMT
 TechTips: The little gotcha called "doDefault"

Quote:

> The "doDefault" statement ensures that the form is completely open and
> initialized before attempting to move the cursor to the control.

well, not necessarily. To be absolutely sure that everything's finished,
you should really put the attempt to move the cursor to the control in
the page::arrive() method. so that it doesn't get moved by some other
default behaviour after you've moved it yourself.

--
Mike Irwin                    It's not because things are hard that we
[Volunteer CTech Sysop,       don't dare them; it's because we don't
not a Corel employee]         dare them that they are hard - Seneca.



Fri, 11 Apr 2003 11:55:03 GMT
 TechTips: The little gotcha called "doDefault"
So it's important to always think about eventInfo.setErrorCode() within
the context of the doDefault construct.  When you use *disableDefault*
it only stops the default action of the current method.  So the event
(bubble) chain continues merrily on its way.  But if you set a non-zero
errorCode then you stop all the subsequent events and reactions that
might occur further on down the line.  There are times when even this
can get complicated and confusing; I have used both in the same method
at times.  Just an additional $.02

NoaH

Sent via Deja.com http://www.deja.com/
Before you buy.



Fri, 18 Apr 2003 20:38:58 GMT
 
 [ 4 post ] 

 Relevant Pages 

1. Pdox 7 (NT) "gotcha's"

2. max of ("...","...","..")

3. TechTips: "Hot Backups?"

4. TechTips: "Table is full?"

5. TechTips: Not a "great big list"

6. TechTips: "Hot Backups?"

7. TechTips QUIZ: What's wrong "!"

8. TechTips: What -is- "reindexing?"

9. TechTips: What -is- "packing?"

10. TechTips: Corrupted tables and "ScanDisk"

11. TechTips: What -is- a "covering lock?"

12. TechTips: "Table is full?"


 
Powered by phpBB® Forum Software