Xojo Conferences
XDCMay2019MiamiUSA

Drawer Questions (Real Studio network user group Mailinglist archive)

Back to the thread list
Previous thread: Re: realbasic-nug Digest, Vol 10, Issue 148
Next thread: MemoryBlock question


Win32 API Declares   -   Berg, Heath
  Drawer Questions   -   Ken Fleisher
   Re: Drawer Questions   -   Adam Ernst
   Re: Drawer Questions   -   Charles Yeomans
    Re: Drawer Questions   -   Ken Fleisher
     Re: Drawer Questions   -   David Glass

Drawer Questions
Date: 30.01.05 03:17 (Sat, 29 Jan 2005 21:17:54 -0500)
From: Ken Fleisher
Hi. I'm trying to use a drawer for the first time and I'm hitting some
walls. The LR doesn't seem to explain this very well (at least I
couldn't find it) and the questions in the archives about drawers are
much more specific than what I'm stuck on. I'm sure the answers are
very simple, but...

I want a window to have a drawer that will be used to enable/disable an
edit mode.

1) I know the command to show the drawer is WindowName.ShowWithin
parentWindow [, facing] What I don't understand is how can I show the
drawer by clicking on a ToolbarItem? Do I need to Dim the drawer window
first? Where should I do that--in the ToolbarItem, the parent window,
somewhere else? If I put the WindowName.ShowWithin in the Action event
of the ToolbarItem, the drawer does show, but how could I then use the
same button to toggle the drawer closed?

2) Once the drawer is showing, how can I close it? In other words, I
want the ToolbarItem to toggle the drawer open and closed. So how can I
tell if the drawer is already showing?

3) If I am using the controls on the drawer to toggle an edit mode
(enabled/disabled using radio buttons on the drawer), how can I tell
what that setting is once the drawer is closed? Is it better to use the
visible property? In other words, does closing a drawer destroy the
window or simply hide it?

Sorry, I'm not too savvy on drawers...

Thanks for the help.

Ken

Re: Drawer Questions
Date: 30.01.05 03:25 (Sat, 29 Jan 2005 20:25:09 -0600)
From: Adam Ernst
> 1) I know the command to show the drawer is WindowName.ShowWithin
> parentWindow [, facing] What I don't understand is how can I show the
> drawer by clicking on a ToolbarItem? Do I need to Dim the drawer
> window first? Where should I do that--in the ToolbarItem, the parent
> window, somewhere else? If I put the WindowName.ShowWithin in the
> Action event of the ToolbarItem, the drawer does show, but how could I
> then use the same button to toggle the drawer closed?

Well, if you're only going to show one instance of the drawer at a time
(that is, you won't have multiple copies of the same drawer open), you
don't need to dim it; you can just use its name and rely on implicit
instantiation. Here's some sample code for toggling:

Sub Action
dim lc as integer
for lc = 0 to windowcount-1
if window(lc) isa MyDrawerWindow then
MyDrawerWindow.close
return
end if
next

MyDrawerWindow.ShowWithin self
End Sub

You need the loop since if you just say "MyDrawerWindow <> Nil",
REALbasic will automatically instantiate it for you, making the
statement alwasy true--not what you want.

> 2) Once the drawer is showing, how can I close it? In other words, I
> want the ToolbarItem to toggle the drawer open and closed. So how can
> I tell if the drawer is already showing?

That's the loop above.

> 3) If I am using the controls on the drawer to toggle an edit mode
> (enabled/disabled using radio buttons on the drawer), how can I tell
> what that setting is once the drawer is closed? Is it better to use
> the visible property? In other words, does closing a drawer destroy
> the window or simply hide it?

You could .Hide the drawer, but then the toggle code above won't work;
you'd have to rewrite it to take hidden drawers into account. In
general, it would probably be best to not rely on the drawer's controls
but instead add some properties to the parent window that the drawer
would modify.

Adam

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Drawer Questions
Date: 31.01.05 00:07 (Sun, 30 Jan 2005 18:07:35 -0500)
From: Charles Yeomans

On Jan 29, 2005, at 9:17 PM, Ken Fleisher wrote:

> Hi. I'm trying to use a drawer for the first time and I'm hitting some
> walls. The LR doesn't seem to explain this very well (at least I
> couldn't find it) and the questions in the archives about drawers are
> much more specific than what I'm stuck on. I'm sure the answers are
> very simple, but...
>
> I want a window to have a drawer that will be used to enable/disable
> an edit mode.
>
> 1) I know the command to show the drawer is WindowName.ShowWithin
> parentWindow [, facing] What I don't understand is how can I show the
> drawer by clicking on a ToolbarItem? Do I need to Dim the drawer
> window first? Where should I do that--in the ToolbarItem, the parent
> window, somewhere else? If I put the WindowName.ShowWithin in the
> Action event of the ToolbarItem, the drawer does show, but how could I
> then use the same button to toggle the drawer closed?

Probably you'd want the parent window to have a property Drawer as
Window. Then you might have code like the following.

Sub ShowDrawer()
If self.Drawer Is Nil then
self.Drawer = new DrawerWindow
End if
self.Drawer.Show
End if

Now call this method in the toolbar item's Action event handler.

>
> 2) Once the drawer is showing, how can I close it? In other words, I
> want the ToolbarItem to toggle the drawer open and closed. So how can
> I tell if the drawer is already showing?
>
> 3) If I am using the controls on the drawer to toggle an edit mode
> (enabled/disabled using radio buttons on the drawer), how can I tell
> what that setting is once the drawer is closed? Is it better to use
> the visible property? In other words, does closing a drawer destroy
> the window or simply hide it?

You can use some Window Manager functions to get this information --

Declare Function GetDrawerState Lib "CarbonLib" (inDrawerWindow as
WindowRef) as Integer

The function returns one of the following values.

kWindowDrawerOpening = 1,
kWindowDrawerOpen = 2,
kWindowDrawerClosing = 3,
kWindowDrawerClosed = 4

I experienced some minor but annoying problems with drawers that I
worked around by writing a Drawer subclass that uses Window Manager
functions in preference to ShowWithin, etc. It's available at
<http://www.quantum-meruit.com/Rb/>. You might find it useful to
examine even if you opt not to use it in your own code.

--------------
Charles Yeomans

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Drawer Questions
Date: 30.01.05 04:24 (Sat, 29 Jan 2005 22:24:29 -0500)
From: Ken Fleisher
> Well, if you're only going to show one instance of the drawer at a
> time (that is, you won't have multiple copies of the same drawer
> open), you don't need to dim it; you can just use its name and rely on
> implicit instantiation. Here's some sample code for toggling:

Adam,

Thanks for the reply. That will work great except I might have more
than one drawer. I only have two window types in the app. A document
window and the drawer window. I can have multiple document windows open
and each should be able to open/close it's own drawer.

So I'll keep a property in the document window for the mode, but what
about now how to tell if the drawer window is open for the window where
the toolbar was clicked (to toggle the drawer)?

Ken

PS I found this in the archives, but the link is dead and I didn't see
it elsewhere on the site. Anyone know where to find this example?:

Interface Examples:
• Toolbar & Drawer - Using StandardToolbarItems and ToolbarItems, this
example shows how to use a toolbar effectively with dynamic images
for toggle feedback such as the showing and hiding of a drawer used
in the project.

The examples are immediately available at the following address:
http://www.freaksw.com/development/realbasic/rb-examples.html

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Drawer Questions
Date: 30.01.05 05:39 (Sat, 29 Jan 2005 20:39:02 -0800)
From: David Glass
Multiple ways to skin this cat. This is how I do it:

Create a property of the parent window: blnDrawerOpen as boolean

In the Action event of the toolbar button do something like this:

if blnDrawerOpen then
wndDrawer.close
blnDrawerOpen = False
else
wndDrawer.show
blnDrawerOpen = True
end if

On Jan 29, 2005, at 19:24, Ken Fleisher wrote:

> , but what about now how to tell if the drawer window is open for the
> window where the toolbar was clicked (to toggle the drawer)?
>