Toolbar question

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

Toolbar question

Bruno Brasesco
Hi all,

I have a view that has a toolbar and a playground.
When I press some toolbar item I want to indicate in the Playground (with
the mouse) where I want to put the Shape (and the toolbar item should be
pressed through all process).

After #addShape command is executed in the Presenter the toolbar item become
unpressed (unchecked).

I want to have a toolbar item that remain pressed until I say it.

Is there any way to do that ?

Best Regards
Bruno Brasesco


Reply | Threaded
Open this post in threaded view
|

Re: Toolbar question

Ian Bartholomew-4
Bruno,

> I want to have a toolbar item that remain pressed until I say it.
>
> Is there any way to do that ?

It's done using the same #queryCommand: method that you use to
enable/disable commands -

YourShell>>queryCommand: aCommandQuery
    super queryCommand: aCommandQuery.
    aCommandQuery command == #startPositioningShape
        ifTrue: [aCommandQuery isChecked: self isPositioningShape]

where #startPositioningShape is the command sent by your toolbar button and
#isPositioningShape is a method answering true while the shape is being
positioned and you want the button so show as depressed.  ToolbarButton also
has an editable aspect, #isCheckStyle, which you can set but it doesn't
appear to make any difference to the operation of the button now, although I
think it _used_ to?.

It is possible to get the the button to maintain it's own checked/unchecked
state but I have found that it can get a bit confusing so I tend to have a
local instance variable to hold the button's state (i.e. the value returned
by #isPositioningShape above) for me.

You _might_ also have to do a little bit of fiddling to allow
Dolphin/Windows to visually update the button when you change the state of
the button programmatically, it depends on your application. It is easy
enough to work around so ask again if it is a problem.

Ian