I needed a GUI with 81 boxes where the user can choose to input one single number (is a board of a game).
So i have subclassed a ComposableModel
with 81 instance variables each one initializing to a new TextInputFieldModel
instance.
The problem is it takes about 6 seconds to open. Why it takes so long to open 81 text boxes? Is there something i could do to speed the opening?
You can use the Profiler for this. I have tried to recreate your UI requirement and run it inside the Tools -> Time Profiler. This is the Code:
| specArray widgets view layout |
" Configure the Spec models "
specArray := OrderedCollection new: 81 * 2.
1 to: 81 do: [ : index | specArray
add: ('textInput' , index asString) asSymbol;
add: #TextInputFieldModel ].
view := DynamicComposableModel new
instantiateModels: specArray;
extent: 300@800;
title: 'Title'
yourself.
" Configure the Spec layout "
widgets := specArray reject: [ : ti | ti = #TextInputFieldModel ].
layout := SpecLayout composed
newColumn: [ : r |
widgets doWithIndex: [ : ti : index | r add: ti ] ];
yourself.
" Set up the widgets "
widgets doWithIndex: [ : each : index | (view perform: each) text: index asString ].
" Open the Window "
(view openWithSpecLayout: layout) delete.
As you can see in the screenshot, most time is spent in TextInputFieldModel>>defaultEntryCompletion so you can try to speed up that section (unfortunately the method is undocummented)
If you apply the Leandro's suggestion you can speed up the from
to
The code in TextInputFieldModel>>defaultEntryCompletion would be:
defaultEntryCompletion
| applicants |
applicants := (Array streamContents: [:strm |
Smalltalk globals keysDo: [ : each | (each notEmpty and: [each first canBeGlobalVarInitial])
ifTrue: [ strm nextPut: each ] ] ]) sort.
^ EntryCompletion new
dataSourceBlock: [:currText | applicants];
filterBlock: [:currApplicant :currText | currText size > 3
and: [currApplicant asUppercase includesSubstring: currText asString asUppercase]].
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With