[Gambas-user] Program going off the rails in a way I can't explain. Help?

Doriano Blengino doriano.blengino at ...1909...
Tue Jan 19 10:12:46 CET 2010


Kadaitcha Man ha scritto:
> 2010/1/19 Doriano Blengino <doriano.blengino at ...1909...>:
>
>   
>> I think that setting up a flag won't hurt anyway, even if it is ugly.
>> The whole GUI world (not only gambas) seems to have this kind of
>> mentality (to raise an event in response to modifications made by code),
>>     
>
> 1) Flags are necessary in any GUI.
>   
??
> 2) Events caused by code should fire as if the user had performed the function.
>
> Otherwise the performing code would have to emulate the control's
> event sequence and there goes OO encapsulation. not to mention the
> need to write unnecessary and oft-repeating code.
>   
Debatable (but I am unwilling to debate).
Is it more oft-repeating and unnecessary to write:

    combo1.add('An item")
    combo1_click   ' would be better to "raise an event to an object"

(note: 2 lines of code, and only one is meaningful to our discussion) or

    private bUpdatingCombo as boolean
    ...
    bUpdatingCombo = true
    combo1.add("An item")
    bUpdatingCombo = false
    ...
    ' (later, in combo1_click)
    if bUpdatingCombo then return
    ...

(note: 4 lines of code needed and a global variable used in three 
different places).

And things can be more complicated than this stupid example if there is 
some inheritance involved - which is the order of execution of the 
several event handler? And should we block every event handler in the 
hierarchy (if it is possible) or just some? What happens behind the 
scenes (encapsulation!)?

Regards,
Doriano




More information about the User mailing list