Groups > dBase > dBase bug reports > Re: Tabbox OnSelChange firing issue




Tabbox OnSelChange firing issue

Tabbox OnSelChange firing issue
Tue, 11 Mar 2008 15:59:06 -040
I have come across a problem with the timing of the OnSelChange event of the 
TABBOX.  When clicking on the TABBOX control, the event fires immediately. 
However, with code such as this:

function somePushbutton_onClick
    some lines of code
    form.pageNo = 2
    form.tabbox1.curSel = 2
   some more lines of code
    return


the OnSelChange does not fire until all of the code has executed and return 
has been encountered.  I feel that the event should fire the moment the code 
executes to change the value.  Or, better yet, the code should not fire at 
all from a programmatic assignment, but only from the user action like some 
other controls behave.

Post Reply
Re: Tabbox OnSelChange firing issue
Wed, 12 Mar 2008 16:19:44 -040
David,

>I have come across a problem with the timing of the OnSelChange event of 
>the TABBOX.  When clicking on the TABBOX control, the event fires 
>immediately. However, with code such as this:
>
> function somePushbutton_onClick
>    some lines of code
>    form.pageNo = 2
>    form.tabbox1.curSel = 2
>   some more lines of code
>    return
>
>
> the OnSelChange does not fire until all of the code has executed and 
> return has been encountered.  I feel that the event should fire the moment

> the code executes to change the value.

If you need it to fire immediately after setting curSel, try adding:

form.tabbox1.onSelChange()   on the following line after setting curSel.

Of course, this will result in onSelChange() firing twice.

If you have code in the onSelChange() event handler that you do not want to 
run
when setting curSel via code, you can create a custom property to serve as a 
flag
for your code to check for.  Before setting curSel directly, set the flag to 
True,
after setting curSel, set the flag back to False.
Within onSelChange(), check the flag value.  If its True, skip any code that 
shouldn't
run.

>  Or, better yet, the code should not fire at all from a programmatic 
> assignment, but only from the user action like some other controls behave.

I understand that its behavior is inconsistent with some other events.
However, this is the documented behavior, so changing it is likely to break 
existing code.

Changing the event to fire immediately rather than queuing it to fire might 
be feasible.
We would need to investigate that further.

Perhaps creating a mechanism to allow you to override the default firing 
method (immediate
versus queued) would be useful.

- Marty -

Martin Kay
dataBased Intelligence, Inc.




Post Reply
about | contact