作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我需要一个带有 81 个框的 GUI,用户可以在其中选择输入一个数字(是游戏的棋盘)。
所以我子类化了一个 ComposableModel
有 81 个实例变量,每个实例变量初始化为一个新的 TextInputFieldModel
实例。
问题是打开大约需要6秒。为什么打开81个文本框需要这么长时间?我可以做些什么来加快打开速度?
最佳答案
您可以为此使用 Profiler。我尝试重新创建您的 UI 要求并在工具 -> 时间分析器中运行它。这是代码:
| 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.
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]].
关于user-interface - 加速 ComposableModel 新 openWithSpec(在 Pharo v3 中),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27758736/
我需要一个带有 81 个框的 GUI,用户可以在其中选择输入一个数字(是游戏的棋盘)。 所以我子类化了一个 ComposableModel有 81 个实例变量,每个实例变量初始化为一个新的 TextI
我是一名优秀的程序员,十分优秀!