tips
[Top] [All Lists]

REALbasic Tip: Better metal windows on Mac OS X

To: REALbasic-tips at lists dot realsoftware dot com
Subject: REALbasic Tip: Better metal windows on Mac OS X
From: Geoff Perlman <geoff at realsoftware dot com>
Date: Wed, 5 May 2004 17:56:37 -0500
Cc:
Delivered-to: REALbasic-tips at lists dot realsoftware dot com
List-help: <mailto:realbasic-tips-request@lists.realsoftware.com?subject=help>
List-id: REALbasic Tips <realbasic-tips.lists.realsoftware.com>
List-post: <mailto:realbasic-tips@lists.realsoftware.com>
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.

<Prev in Thread] Current Thread [Next in Thread>
  • REALbasic Tip: Better metal windows on Mac OS X, Geoff Perlman <=