|
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
|