eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'EditFieldWithCompletion':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: EditFieldWithCompletion


Inheritance:

   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

Description:


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:]

copyright

COPYRIGHT (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.

Instance protocol:

accepting
o  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
o  showOptions

o  showOptions: aBoolean

accessing-dimensions
o  absoluteLeft
answer the absolute left (x) coordinate (i.e. relative to the display)

o  absoluteTop
answer the absolute top (y) coordinate (i.e. relative to the display)

accessing-mvc
o  optionsHolder

o  optionsHolder: aValueHolder
set the 'options' value holder (automatically generated)

event handling
o  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
].

o  handleNonCommandKey: char
(comment from inherited method)
pasted selection will NOT be replaced by keystroke

o  handlesKeyPress: key inView: aView

o  hasKeyboardFocus: gotFocusBoolean
no change

o  keyPress: key x: x y: y
Forward certain events to optionsView if any

o  keyPress: key x: x y: y view: aView

o  tabCompletion: best options: options
options size > 1

o  updateContentsForLongest: best options: options

initialization & release
o  destroy
(comment from inherited method)
unmap & destroy - make me invisible, destroy subviews then
make me unknown to the device

o  initialize

private
o  doCompletion

o  doCompletionThenSend: selector
(options includes:best) ifFalse:[

o  doTabCompletion

o  hideOptionsWindow

o  showOptionsWindow
JV: Looks good to me

o  startCompletion

o  startTabCompletion


Examples:


    |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


ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Mon, 18 Nov 2024 08:43:36 GMT