Skip to content

Commit

Permalink
Merge pull request #365 from seandenigris/enh_gt-action-pass-obj
Browse files Browse the repository at this point in the history
[Enh]: GT Action Blocks - Pass Described Object
  • Loading branch information
seandenigris authored Sep 30, 2024
2 parents f387bf3 + 7b10bab commit 6d46b62
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions source/Magritte-GToolkit/MAActionDescription.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Extension { #name : #MAActionDescription }
MAActionDescription >> gtAction: aValuable [
"aValuable - optional arguments:
- aGtPhlowNoAction (same as the argument to a standard GT action method)
- this description
- NB. the receiver is *not* passed as an argument, because it should be available in the description creation method"
- the receiver. Although it is available in the description creation method, it is a best practice not to use self in descriptions because descriptions are designed to be late bindable to any compatible object
- this description"

self flag: 'RE the last argument NB, the receiver SHOULD be passed, because descriptions are designed to be independent of model and applied to any compatible'.

Expand All @@ -20,17 +20,22 @@ MAActionDescription >> gtActionOf: anObject [
^ self
propertyAt: #gtAction
ifPresent: [ :valuable |
valuable cull: GtPhlowAction noAction cull: self ]
ifAbsent: [
| button icn |
button := GtPhlowAction noAction button.
self comment ifNotEmpty: [ :tt | button tooltip: tt ].
icn := self gtIcon ifNil: [ self icon ].
icn ifNotNil: [ :i | button icon: i ].
self isLabelVisible ifTrue: [ button label: self label ].
button
action: [ self performOn: anObject ];
yourself ].
valuable cull: GtPhlowAction noAction cull: anObject cull: self ]
ifAbsent: [ self gtButtonFor: anObject ].
]

{ #category : #'*Magritte-GToolkit' }
MAActionDescription >> gtButtonFor: anObject [

| button icn |
button := GtPhlowAction noAction button.
self comment ifNotEmpty: [ :tt | button tooltip: tt ].
icn := self gtIcon ifNil: [ self icon ].
icn ifNotNil: [ :i | button icon: i ].
self isLabelVisible ifTrue: [ button label: self label ].
^ button
action: [ self performOn: anObject ];
yourself.
]

{ #category : #'*Magritte-GToolkit' }
Expand Down

0 comments on commit 6d46b62

Please sign in to comment.