Manipulating menus and toolbars

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Manipulating menus and toolbars

Andrew Lawson-2
All
    As a Dolphin newbie I've reached the point in my first serous app
where I'm polishing the menus and toolbars. I've come across a few
questions that I'd be very happy to have answered.

1) What is the easiest (most idiomatic) way of enabling/disabling
menu/toolbar options, the classes in question are fairly complex and I
want to make sure I do this without resorting to an ugly hack.

2) Is there any way of enabling/disabling these options using callbacks
so that they look after their own state depending on a user-defined
function.

3) Because toolbars are usually just a graphical extension of menu
options, is there any way of linking them so that they can be
manipulated as one, i.e. disabling file->exit will  also disable the
exit button.

            thanks in advance

                    Andrew

--
     Andrew Lawson
  [hidden email]
http://www.absentis.com


Reply | Threaded
Open this post in threaded view
|

Re: Manipulating menus and toolbars

Ian Bartholomew-18
Andrew,

>     As a Dolphin newbie I've reached the point in my first serous app
> where I'm polishing the menus and toolbars. I've come across a few
> questions that I'd be very happy to have answered.
>
> 1) What is the easiest (most idiomatic) way of enabling/disabling
> menu/toolbar options, the classes in question are fairly complex and I
> want to make sure I do this without resorting to an ugly hack.

Dolphin uses a system based around the #queryCommand: method that you
will find defined in a lot of Presenter and View subclasses.  Basically,
when a menu is shown and during any idle time (for Toolbars)
queryCommand: is called for each command that can be invoked from the
Presenter.  You can then programmatically enable/disable (or
check/uncheck) the command and all menus and toolbars will reflect the
new state..

You should get the idea by looking at a few #queryCommand: methods in
the image but if not then ask again or have a look through the newsgroup
archive where it has been discussed a number of times.

> 2) Is there any way of enabling/disabling these options using
> callbacks so that they look after their own state depending on a
> user-defined function.

Because of the above the enabling/disabling is transparent (most of the
time) and once set up you don't have to get involved in updating things
manually..

> 3) Because toolbars are usually just a graphical extension of menu
> options, is there any way of linking them so that they can be
> manipulated as one, i.e. disabling file->exit will  also disable the
> exit button.

As you enable/disable the command itself, and not the menu items or
toolbar buttons, then all sources of that command automatically reflect
the required state.

--
Ian

Use the Reply-To address to contact me.
Mail sent to the From address is ignored.