current drawer

Hi,

I have two drawers and two buttons assigned to the same. if i click on one button then drawer opens and if i click on second button then that drawer open under the first drawer, so its not visible. i want to close current open drawer and then open new drawer.

i have tried following:

on Push_(sender)

set currentDrawer to curent application’s NSDrawer -----assigning current open drawer to currentDrawer
set drawerState to current application’s NSDrawerOpenState ----assigning value of currently open drawer

if drawerState as integer is 2 then

currentDrawer’s |close|() ----closing current open drawer

myDrawer’s |open| () --myDrawer linked to drawer to be opened.

end if

end Push_

but its not working, it says “unrecognised selector sent to class”

pl,s help

This line doesn’t do what you think it’s doing – all that does is set the variable currentDrawer to the class NSDrawer, not to your current drawer. You need to have IBOutlets for your 2 drawers, say drawer1 and drawer2. Then in the action methods for your buttons send close to one and open to the other:

on openDrawer1_(sender)
		drawer2's |close|()
		drawer1's |open|()
	end openDrawer1_
	
	on openDrawer2_(sender)
		drawer1's |close|()
		drawer2's |open|()
	end openDrawer2_

Ric

thank you ric,

but i have six buttons on the window and it opens six different drawers. these drawers contains different buttons. so user can open any drawer according to his choice. therefore, is there any method to close the currently opened drawer and then open new drawer.

thanks again

anybody has any solution for this problem???

please help

define a instance variable currentOpenedDrawer (or whatever name you like).
Every time a drawer opens, assign the object reference to this instance variable.

pseudo code:

on openDrawer(theDrawer)
if currentOpenedDrawer is not nil and currentOpenedDrawer is open then close currentOpenedDrawer
open theDrawer
set currentOpenedDrawer to theDrawer
end

hi stefan,

thank you for your reply.

i am little bit confused. i have six buttons on main window to open different drawers.

for example i am writing following code to open drawer1 with button 1.

on Push_(sender)

myDrawer’s |open| () —myDrawer linked to Drawer1.

end Push_

now, the code you have written, where should i put that. i know its very stupid question, but please help me in this.

thank

just call the method with the appropriate drawer as parameter

on Push_(sender)
openDrawer(myDrawer)
end Push_

the code I’ve written is pseudo code, it doesn’t work actually
The method is a subroutine like push_(), put it somewhere within the script’s scope

is there any method to close any drawer opened…???

it’s unlikely because (a) drawers are discouraged these days, and (b) the idea of having more than one, let alone six, would probably give someone in Cupertino apoplexy…

It would be a good idea for you to describe what you are trying to do with all these drawers. The latest Apple Human Interface Guidelines say:

Drawers are rarely used in modern Mac OS X apps. As much as possible, redesign your UI to avoid using drawers; if you’re creating a new app, avoid adding a drawer to the design. Typically, a drawer contains frequently accessed controls that don’t need to be visible at all times.

Certainly, you shouldn’t have 6 drawers for “frequently accessed controls”.

Ric