[Gambas-user] How to stop a control raising events?
Tony Morehen
tmorehen at ...3602...
Mon Aug 14 01:54:18 CEST 2017
Careful, though, Object.Lock inhibits all events associated with a
control, including events from internal controls. For example, DirView
has an internal TreeView control. When you click on a folder or set the
Current property in code, DirView tells the TreeView to expand that
branch. TreeView then raises the Expand event, requesting that DirView
fill in the sub-folders of that branch. After that is done, DirView
raises its click event.
I wanted the click event to only occur when the user clicks on a folder
so I surrounded the code setting DirView.Current with
object.lock/unlock. All of a sudden, DirView stopped updating
properly. This seemed to occur only during the initialization of
DirView. It took me 2 days to figure out that the object.lock stopped
the TreeView Expand event so DirView did not update. Another control was
setting the DirView Current property during its initialization, not any
of my own code, which made debugging even harder.
I wound up replacing the object.lock with a boolean flag. When set, the
flag stops the Click event code from running.
On 2017-08-13 06:18 PM, Tobias Boege wrote:
> On Mon, 14 Aug 2017, adamnt42 at ...626... wrote:
>> (A quicky!)
>>
>> Wasn't there a way to temporarily stop a control raising events, MyControl.Lock or somesuch? My memory fails!
>> tia
>> bruce
> Object.Lock(x)
>
More information about the User
mailing list