|
From: Alex T. <al...@tw...> - 2005-04-26 21:51:00
|
I've been looking into the "flaky behaviour while resizing" that various
people have mentioned (I have to admit I hadn't noticed it myself, but
was able to make it happen fairly easily once I started trying).
I'm pretty sure I know what the problem is - but not yet 100% sure I
have the *right* solution; so if anyone is familiar with this aspect of
the code, and can confirm my thoughts, I'd be grateful. If someone who
isn't familiar with it would be willing to offer an opinion - I'd still
be grateful for that :-)
There is a chunk of code (see below) at the start of the doResize()
function. Normally, you get here indirectly from on_mouseDrag(), because
of a wxPython event captured because of
wx.EVT_MOTION(self.panel, self.on_mouseDrag)
So, normally, the "try" clause fails - wxPython events have no member
event.x, and the "except" clause is used. (i.e. ignore the comments
about Windows vs Mac/Linux).
However, if you are extending the right side of say a Textfield
outwards, and then move back to the left rapidly, you generate a
mouseDrag event *within* the textfield - and hence a PythonCard event
triggers on_mouseDrag(). This gets through the "try" clause - and, well,
almost anything can happen - you start mixing client and screen coords.
I *think* the "try" clause is simply obsolete code, from some earlier
incarnation when the Windows version used a different event capture
mechanism, and the fix is to simply remove the "try ...... except"
lines. This certainly *seems* to work in my testing - but I'm still wary
of just doing that without some confirmation.
> def doResize(self, event, (n, w, s, e)):
> if not self.startName:
> return
>
> try:
> # Windows
> xOffset = event.x - self.offset[0]
> yOffset = event.y - self.offset[1]
> except:
> # Mac OS X and Linux/GTK
> #x, y = event.GetPosition()
> globalPosition = wx.GetMousePosition()
> x, y =
> self.components[self.resizingHandleTarget].ScreenToClient(globalPosition)
> xOffset = x - self.offset[0]
> yOffset = y - self.offset[1]
>
> xStartOffset = self.startPosition[0] + e * xOffset
> yStartOffset = self.startPosition[1] + n * yOffset
-- Alex.
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.10.3 - Release Date: 25/04/2005
|