OpaqueImageWithEnablement>>displayOn:at:enabled:

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

OpaqueImageWithEnablement>>displayOn:at:enabled:

Ladislav Lenart
Hi,

I have a UI with button which has OpaqueImageWithEnablement as its label.
The enablement of the button changes according to some state of the UI
(list selections).
The label image is obtained from ToolbarIconLibrary class via
#visualFor: method.
It consists of three CachedImages: activeFigure, activeShape and
inactiveShape (inactiveFigure isNil).
The problem is that sometimes the inactiveShape is displayed instead of
activeFigure & activeShape pair.
I debug this and finally found that OpaqueImageWithEnablement ignores
enabled boolean in its #displayOn:at:enabled: method which itself is not
a big deal, BUT its isActive is false while a supplied aBoolean (actual
state of the button) is true.

The 'hot fix' that seems to work for me is this:

OpaqueImageWithEnablement>>displayOn: aGraphicContext at: aPoint
enabled: aBoolean

    | oldIsActive |
    oldIsActive := isActive.
    self isEnabled: aBoolean.
    self displayOn: aGraphicContext at: aPoint.
    isActive := oldIsActive.

Am I doing something wrong or is this a bug or what?

BTW I also tried using OpaqueImage instead but this didn't look good at all.

Ladislav Lenart