If your application allows the user to open more than one window at a
time,
all controls in all windows except the frontmost window (and any
floating
windows) should be disabled. This prevents the user from learning to
double-click on controls to get them to work (because they don't realize
that the first click activated the window).
REALbasic should handle this for you and will in a future release.
However,
you can add this capability to your windows easily. The basic idea is
to add
a boolean array to each window that will keep track of the enabled
state of
each control. When a window is deactivated, code in the Deactivate
event of
the window stores in the boolean array the current state of each control
then disables each control. The Activate event of the window then
resets the
enabled state of each control based on the corresponding value in the
boolean array.
Steps:
1. Add a boolean array to each window using the following declaration:
enabledState(0) as boolean
2. Add the following code to the deactivate event of each window:
dim i as integer
redim enabledState(controlCount)
for i = 0 to controlCount - 1
if control(i) isa rectcontrol then
enabledState(i) = rectcontrol(control(i)).enabled
rectcontrol(control(i)).enabled = false
end if
next
3. Add the following code to the activate event of each window:
dim i as integer
if ubound(enabledState) > 0 then
for i = 0 to controlCount - 1
if control(i) isa rectcontrol then
rectcontrol(control(i)).enabled = enabledState(i)
end if
next
redim enabledState(0)
end if
Now when a window is deactivated, all of its controls will be disabled.
When
the window is activated again, the controls will return to their
previously
enabled state.
One thing you will need to consider when using this technique is
whether or
not your project enables or disables controls in deactivated windows.
For
example, your project might have one window that tells controls in other
windows to be enabled or disabled. If that's the case, you will need to
make
sure you update the boolean array for that window of when the window is
activated, the control won't have the correct enabled state.
--
Geoff Perlman
President & CEO
REAL Software, Inc.
http://www.realsoftware.com
mailto:geoff at realsoftware dot com
Phone: 512-263-1233 x711
Fax: 512-263-1441
- - - - - - - - - -
Got a useful tip to share? Send it to us at:
REALbasic-tips at lists dot realsoftware dot com dot
For list commands, send "Help" in the body of a message to
<requests at lists dot realsoftware dot com>
|