|
Class: EditFieldWithCompletion
Object
|
+--GraphicsMedium
|
+--DisplaySurface
|
+--SimpleView
|
+--View
|
+--ListView
|
+--TextView
|
+--EditTextView
|
+--EditField
|
+--EditFieldWithCompletion
- Package:
- stx:libtool
- Category:
- Views-Text
- Version:
- rev:
1.23
date: 2023/04/24 14:50:39
- user: stefan
- file: EditFieldWithCompletion.st directory: libtool
- module: stx stc-classLibrary: libtool
an editfield, which does some completion on the Tab key.
it is setup with:
entryCompletionBlock:[:content | <generate completions>]
where completions are
as generated eg. by
Smalltalk classnameCompletion:content
which generates a 2 entry collection:
1st: the best (longest) match
2nd: collection consisting of matching strings
[instance variables:]
[class variables:]
copyrightCOPYRIGHT (c) 2006 by eXept Software AG
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
accepting
-
accept
-
(comment from inherited method)
accept the current contents by executing the accept-action and/or
changeMessage.
Do this only if the contents of the EditField differs
from the printed representation of the model.
accessing-behavior
-
showOptions
-
-
showOptions: aBoolean
-
accessing-dimensions
-
absoluteLeft
-
answer the absolute left (x) coordinate (i.e. relative to the display)
-
absoluteTop
-
answer the absolute top (y) coordinate (i.e. relative to the display)
accessing-mvc
-
optionsHolder
-
-
optionsHolder: aValueHolder
-
set the 'options' value holder (automatically generated)
event handling
-
completion: best options: options
-
oldContent := ((self contents ? '') asString).
newContent := ((best isNil or:[ best = oldContent ])
and:[ options isNilOrEmptyCollection not ])
ifTrue:[
options first
options inject:options anyOne
into:[:shortest :each |
shortest asString size > each asString size ifTrue:[
each
] ifFalse:[ shortest ]
]
]
ifFalse:[ best ].
self contents:newContent asString.
self cursorCol:oldContent size + 1.
oldContent size < newContent size ifTrue:[
self
selectFromLine:1
col:oldContent size + 1
toLine:1
col:newContent size
].
-
handleNonCommandKey: char
-
(comment from inherited method)
pasted selection will NOT be replaced by keystroke
-
handlesKeyPress: key inView: aView
-
-
hasKeyboardFocus: gotFocusBoolean
-
no change
-
keyPress: key x: x y: y
-
Forward certain events to optionsView if any
-
keyPress: key x: x y: y view: aView
-
-
tabCompletion: best options: options
-
options size > 1
-
updateContentsForLongest: best options: options
-
initialization & release
-
destroy
-
(comment from inherited method)
unmap & destroy - make me invisible, destroy subviews then
make me unknown to the device
-
initialize
-
private
-
doCompletion
-
-
doCompletionThenSend: selector
-
(options includes:best) ifFalse:[
-
doTabCompletion
-
-
hideOptionsWindow
-
-
showOptionsWindow
-
JV: Looks good to me
-
startCompletion
-
-
startTabCompletion
-
|top field label value|
top := StandardSystemView new.
top
extent:300 @ 300;
label:'Live class completion field'.
value := '' asValue.
field := self new
origin:10 @ 135 corner:280 @ 165;
entryCompletionBlock:[:content | Smalltalk classnameCompletion:content ];
model:value.
label := Label new
origin:10 @ 95 corner:280 @ 115;
labelChannel:value.
top
add:field;
add:label;
open
|
|