Note: This is a Mac OS X-specific tip.
Most of the time when you click and drag a metal window anywhere on the
metal part of the window, you want to drag it. This is the way the
Finder windows work in Mac OS X 10.3 Panther. Metal windows in
REALbasic applications don't do this by default because there are times
when you would not want this behavior. Say for example, you're writing
a paint program that is using a metal window and you need the user to
be able to drag to select a region on the background of the window. If
that started to move the window, the user would not be able to select a
region.
For those times when you do want to drag a metal window by clicking on
the window and dragging, there is an easy way to add this behavior:
First add two properties to the window:
MouseStartX As Integer
MouseStartY As Integer
In the MouseDown event of the window, add the following code to record
the starting position of the drag and to allow the drag to occur:
mouseStartX = X
mouseStartY = Y
Return True
Finally, in the MouseDrag event of the window, add the following code
to set the position of the window based on the difference between the
current position of the mouse and the position it was in when you
started dragging:
me.Left = me.Left + (X - mouseStartX)
me.Top = me.Top + (Y - mouseStartY)
This tip was suggested by Russ Martin.
--
Geoff Perlman
President and CEO
REAL Software, Inc.
|