Skip to content

SpAbstractWidgetPresenter>>#isEnabled is not implemented correctly #1559

@koendehondt

Description

@koendehondt

SpAbstractWidgetPresenter>>#enabled: is implemented as:

enabled: aBooleanOrValuable
	"Set if the widget is enabled (clickable or focusable).
	This can either be a boolean or a block returning a boolean."

	enabled := aBooleanOrValuable

but SpAbstractWidgetPresenter>>#isEnabled is implemented as:

isEnabled
	"Answer if presenter is enabled"

	^ enabled

so that

presenter := SpPresenter new.
button := SpButtonPresenter new
	icon: (presenter iconNamed: #smallSave);
	enabled: [ false ];
	action: [ button inspect ];
	yourself.
presenter layout: (SpBoxLayout newLeftToRight
	add: button;
	yourself).
presenter open

fails with NonBooleanReceiver: proceed for truth.

SpAbstractWidgetPresenter>>#enabled: allows a aBooleanOrValuable argument, so the implementation of SpAbstractWidgetPresenter>>#isEnabled should be:

isEnabled
	"Answer if presenter is enabled"

	^ enabled value

Please note that this bug makes code examples in the Spec book unusable. cc @Ducasse.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions