Skip to content

Commit

Permalink
improve ToLabel editor handling
Browse files Browse the repository at this point in the history
  • Loading branch information
plantec committed Nov 16, 2023
1 parent baffcdb commit b52558b
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 15 deletions.
31 changes: 19 additions & 12 deletions src/Toplo-Widget-Album/ToLabel.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ ToLabel >> addEditorEvent: anEvent [
self editor requestFocus.
self editor selecter
all;
apply

apply.
self editorBuilder value: self editor value: self
]

{ #category : 'accessing' }
Expand Down Expand Up @@ -113,6 +113,20 @@ ToLabel >> editor [
^ self userData at: #editor ifAbsent: [ ]
]

{ #category : 'accessing' }
ToLabel >> editorBuilder [
" returns a valuable that takes the editor and the label as arguments "

^ self userData at: #editorBuilder ifAbsentPut: [ :ed :theLabel | ]
]

{ #category : 'accessing' }
ToLabel >> editorBuilder: aValuable [
" aValuable takes the editor and the label as arguments "

self userData at: #editorBuilder put: aValuable
]

{ #category : 'api - text style' }
ToLabel >> foreground: aBlPaint [

Expand Down Expand Up @@ -162,20 +176,13 @@ ToLabel >> initialize [
self addEventHandler: self defaultEventHandler
]

{ #category : 'initialization' }
{ #category : 'private-editing' }
ToLabel >> initializeEditorFrameBuilder [

self isEditable
ifTrue: [
frameHandler := ToAnchoredWindowHandler new.
frameHandler positionHook: [ :event :theLabel |
theLabel innerElement bounds inSpace bounds topLeft
- (theLabel editor padding left
@ theLabel editor padding top) ].
frameHandler element: self.
frameHandler builder: [ :anchWin :label |
anchWin root addChild: self newEditor.
self editor text: self text copy ] ]
frameHandler := ToLabelEditorWindowHandler new.
frameHandler element: self]
ifFalse: [
frameHandler ifNil: [ ^ self ].
frameHandler element: nil.
Expand Down
13 changes: 13 additions & 0 deletions src/Toplo-Widget-Album/ToLabelEditorWindow.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Class {
#name : 'ToLabelEditorWindow',
#superclass : 'ToAnchoredWindow',
#category : 'Toplo-Widget-Album-Label',
#package : 'Toplo-Widget-Album',
#tag : 'Label'
}

{ #category : 'accessing' }
ToLabelEditorWindow >> defaultElevation [

^ BlRelativeElevation elevation: (SmallInteger maxVal - 200)
]
33 changes: 33 additions & 0 deletions src/Toplo-Widget-Album/ToLabelEditorWindowHandler.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Class {
#name : 'ToLabelEditorWindowHandler',
#superclass : 'ToAnchoredWindowHandler',
#category : 'Toplo-Widget-Album-Label',
#package : 'Toplo-Widget-Album',
#tag : 'Label'
}

{ #category : 'initialization' }
ToLabelEditorWindowHandler >> defaulPositionHook [

^ [ :event :theLabel |
theLabel innerElement bounds inSpace bounds topLeft
- (theLabel editor padding left
@ theLabel editor padding top) ]
]

{ #category : 'initialization' }
ToLabelEditorWindowHandler >> initialize [

super initialize.
self builder: [ :anchWin :label |
| ed |
ed := label newEditor.
anchWin root addChild: ed.
ed text: label text copy ]
]

{ #category : 'accessing' }
ToLabelEditorWindowHandler >> windowClass [

^ ToLabelEditorWindow
]
6 changes: 3 additions & 3 deletions src/Toplo-Widget-Album/ToTextField.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ ToTextField >> initialize [
adjustMousePosition: false;
shareEvents: {
BlMouseDownEvent.
"BlDragEvent.
BlDragEvent.
BlDragStartEvent.
BlDragEndEvent.
BlDragEnterEvent.
Expand All @@ -47,9 +47,9 @@ ToTextField >> initialize [
BlMouseOverEvent.
BlDoubleClickEvent.
BlFocusEvent.
BlBlurEvent" }.
BlBlurEvent }.
self addEventHandler: sharedDistributor.
self next addEventHandler: sharedDistributor.
"self next addEventHandler: sharedDistributor."
self infinite addEventHandler: sharedDistributor.

]
Expand Down

0 comments on commit b52558b

Please sign in to comment.