NAME
Padre::Wx::TreeCtrl::ScrollLock - Scroll-free transactions for tree controls
SYNOPSIS
SCOPE: {
my $lock = $padre_wx_treectrl->scroll_lock;
# Change the tree here
}
# The tree will unlock before here
DESCRIPTION
Ny default a Wx TreeCtrl object will auto-scroll to the location of an expand event or similar actions, as if it had been triggered by a human.
For trees which are supposed to expanding or moving around on their own, this looks quite bizarre.
This class provides an implementation of a "scroll lock" for short-lived sections of fully self-contained code that will be updating the structure of a tree control.
When created, the lock will create a Wx update locker for speed and flicker free changes to the tree. It will additionally remember the current scroll position of the tree.
When destroyed, the lock will move the scroll position back to the original location if it has been changed in the process of an operation and then release the update lock.
The result is that all operations on the tree should occur with the tree appearing to stay fixed in place.
Note that the lock MUST be short-lived, as it does not integrate with the rest of Padre's locking system. You should already have all the data needed to change the tree prepared and ready to go before you create the tree lock.
TODO
Find a way to prevent scrolling in native Wx and remove this class entirely. This whole exercise feels like a bit of a waste of time, because it emulates a more simple behaviour out of complex behaviour just because we can't disable the complex behaviour.
COPYRIGHT
Copyright 2008-2011 The Padre development team as listed in Padre.pm.
LICENSE
This program is free software; you can redistribute it and/or modify it under the same terms as Perl 5 itself.