VAST: "extended" listbox behavior 
Author Message
 VAST: "extended" listbox behavior

Hello Smalltalkers,

I encountered a problem you may already have a
solution for, so I don't need to reinvent the
wheel ;o)

We want to have the possibility to select entries
in listboxes by typing more than one characters
like it is possible in other languages.
For example if I had an ordinary
AbtDropDownListComboBox of VAST 4.5 with the
entries:

    ...
    Eagle
    Elephant
    Lion
    ...

And I entered "e" in the listbox "Eagle" would be
selected. If I entered "l" after that "Lion" would
be selected, but we like to have "Elephant"
selected instead because "el" are the first two
letters.

Is there any possibility to setup listboxes in VA
to behave like this?
Or are there extensions for VAST out there which
do something like this?

Thank you in advance

   -Jrgen Bullinger

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Wed, 18 Jun 1902 08:00:00 GMT  
 VAST: "extended" listbox behavior
Hello Smalltalkers,

I encountered a problem you may already have a
solution for, so I don't need to reinvent the
wheel ;o)

We want to have the possibility to select entries
in listboxes by typing more than one characters
like it is possible in other languages.
For example if I had an ordinary
AbtDropDownListComboBox of VAST 4.5 with the
entries:

    ...
    Eagle
    Elephant
    Lion
    ...

And I entered "e" in the listbox "Eagle" would be
selected. If I entered "l" after that "Lion" would
be selected, but we like to have "Elephant"
selected instead because "el" are the first two
letters.

Is there any possibility to setup listboxes in VA
to behave like this?
Or are there extensions for VAST out there which
do something like this?

Thank you in advance

   -Juergen Bullinger

Sent via Deja.com http://www.deja.com/
Before you buy.



Wed, 18 Jun 1902 08:00:00 GMT  
 VAST: "extended" listbox behavior

Quote:

> Hello Smalltalkers,

> I encountered a problem you may already have a
> solution for, so I don't need to reinvent the
> wheel ;o)

> We want to have the possibility to select entries
> in listboxes by typing more than one characters
> like it is possible in other languages.
> For example if I had an ordinary
> AbtDropDownListComboBox of VAST 4.5 with the
> entries:

>     ...
>     Eagle
>     Elephant
>     Lion
>     ...

> And I entered "e" in the listbox "Eagle" would be
> selected. If I entered "l" after that "Lion" would
> be selected, but we like to have "Elephant"
> selected instead because "el" are the first two
> letters.

> Is there any possibility to setup listboxes in VA
> to behave like this?
> Or are there extensions for VAST out there which
> do something like this?

> Thank you in advance

>    -Juergen Bullinger

We encountered a need for this same functionality and ended up
subclassing AbtDropDownListComboBox.  After making the changes and
getting the new widget working properly (although I still need to go
back and clean it up a little) we contacted IBM and asked them about
including this functionality in the next version of VisualAge.  We
offered our solution and suggested that perhaps they could even add an
indicator to determine what sort of searching you wanted to use on your
list box so that people used to using it as it was wouldn't be effected.
Their response was that not enough people wanted this kind of search
feature and so they wouldn't consider adding it to VisualAge.  The
following are the methods we either added or overwrote in the subclass:

Note: two new instance variables were also created (along with
accessors) called: currentSelectedItem and searchBuffer

******************
currentSelectedItem
        "Return the value of currentSelectedItem."

        ^currentSelectedItem

******************
currentSelectedItem: aString
  "Save the value of currentSelectedItem."

  currentSelectedItem := aString.
  self signalEvent: #currentSelectedItem
    with: aString.

******************
searchBuffer
  "Return the value of searchBuffer."

  searchBuffer isNil ifTrue: [self searchBuffer:''].
  ^searchBuffer

******************
searchBuffer: aString
  "Save the value of searchBuffer."

  searchBuffer := aString.
  self signalEvent: #searchBuffer
    with: aString.

******************
buttonPressed: listWidget clientData: clientData event: event

  " If a user manually selects an item in the list with the mouse,
    then reset the searchBuffer "

  | buttonNumberPressed eventKeySym |

  buttonNumberPressed := event button.

  buttonNumberPressed = 1
  ifTrue: [ self searchBuffer: ''.
    self widget selectedItems isEmpty
      ifTrue: [ self currentSelectedItem: nil ]
      ifFalse: [ self currentSelectedItem:
        (self widget selectedItems at: 1) ].
  ].

******************
keyPressed: listWidget clientData: clientData event: event

  " Process the input keys to select the item in the list "

  | eventString eventKeySym tempIndex |

  eventString := event character asString.
  eventKeySym := event keysym.

  (#($A $B $C $D $E $F $G $H $I $J $K $L $M $N $O $P $Q $R $S $T $U $V
$W $X $Y $Z
$a $b $c $d $e $f $g $h $i $j $k $l $m $n $o $p $q $r $s $t $u $v $w $x
$y $z
$1 $2 $3 $4 $5 $6 $7 $8 $9 $0) includes: event character)
  ifTrue:[ self searchBuffer: (self searchBuffer, eventString)].

  eventKeySym = 65293   "enter key"
   ifTrue: [ ^self searchBuffer: nil ].

  eventKeySym = 65288   "backspace key"
   ifTrue: [ self searchBuffer: (self searchBuffer copyFrom: 1 to:
      (self searchBuffer size - 1)) ].

  "If the user manually selects an item using the UP or DOWN arrows,
          then reset the searchBuffer"
  eventKeySym = 65362 "UP arrow"
   ifTrue: [self searchBuffer: ''.
      tempIndex := self widget userData converterManager
displayableStrings indexOf: self currentSelectedItem.
      (tempIndex notNil and: [ tempIndex > 1 ])
        ifTrue: [ self currentSelectedItem:
          (self widget userData converterManager displayableStrings at:
tempIndex - 1)
        ].
   ].

  eventKeySym = 65364 "DOWN arrow"
   ifTrue: [self searchBuffer: ''.
     tempIndex := self widget userData converterManager
displayableStrings indexOf: self currentSelectedItem.
     (tempIndex notNil and: [ tempIndex < self widget userData
converterManager displayableStrings size ])
        ifTrue: [ self currentSelectedItem:
          (self widget userData converterManager displayableStrings at:
tempIndex + 1)
         ].
   ].

  eventKeySym = 65289   "tab key"
   ifTrue: [    ^nil ].

  eventKeySym = 65505   "shift key"
   ifTrue: [    ^nil ].

  (self searchBuffer = '')
    ifTrue: [self selectedItem: nil]
    ifFalse: [ self widget items
      do: [ :item | (searchBuffer asUppercase abtOccursIn: item
asUppercase at: 1)

ifTrue:[self selectedItem: item.
             self currentSelectedItem: item.
             ^self widget setString: item.]
          ].
    ].

  "override the following base behavior -  when the same character is
  typed several times, the next word starting with that character is
  selected. Instead of this behavior, just leave the currently selected
  item the same."

  self selectedItem = self currentSelectedItem
   ifTrue: [ ^nil ].
  self selectedItem: self currentSelectedItem.
  self widget setString: self currentSelectedItem.

******************
postCreationInitialization

  super postCreationInitialization.

  widget
    addEventHandler: KeyPressMask
       receiver: self
       selector: #keyPressed:clientData:event:
       clientData: nil.

  widget
    addEventHandler: ButtonPressMask
       receiver: self
       selector: #buttonPressed:clientData:event:
       clientData: nil.

Hope this helps!

--

Michael J. Gold
Midwest Consulting Group

Sent via Deja.com http://www.deja.com/
Before you buy.



Wed, 18 Jun 1902 08:00:00 GMT  
 VAST: "extended" listbox behavior
Hello Michael,

thank you for your reply.


Quote:

> We encountered a need for this same functionality and ended up
> subclassing AbtDropDownListComboBox.  After making the changes and
> getting the new widget working properly (although I still need to go
> back and clean it up a little) we contacted IBM and asked them about
> including this functionality in the next version of VisualAge.  We
> offered our solution and suggested that perhaps they could even add an
> indicator to determine what sort of searching you wanted to use on
your
> list box so that people used to using it as it was wouldn't be
effected.
> Their response was that not enough people wanted this kind of search
> feature and so they wouldn't consider adding it to VisualAge.  The
> following are the methods we either added or overwrote in the
subclass:

Strange attitude of IBM!
I guess there are more people out there who would like to have this
feature in VA!

Anyway, I implemented the combobox like you described it.
What I saw so far it works fine!

Thanks
    -Juergen Bullinger

Sent via Deja.com http://www.deja.com/
Before you buy.



Wed, 18 Jun 1902 08:00:00 GMT  
 VAST: "extended" listbox behavior

Quote:

> Strange attitude of IBM!
> I guess there are more people out there who would like to have this
> feature in VA!

> Anyway, I implemented the combobox like you described it.
> What I saw so far it works fine!

> Thanks
>     -Juergen Bullinger

In IBM's defense, In response to my previous posting, I did receive an
e-mail from someone on the VisualAge Smalltalk Team asking who it was
that we talked to at IBM that told us they (IBM) weren't interested in
our modification, so perhpas we may see this feature in the next release
of VisualAge!

--

Michael J. Gold
Midwest Consulting Group

Sent via Deja.com http://www.deja.com/
Before you buy.



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. VAST Manual Like VW "Cookbook".

2. string.join(["Tk 4.2p2", "Python 1.4", "Win32", "free"], "for")

3. "Old fashioned" menu-behavior

4. "weird" behavior of __file__ attribute

5. On the standard behavior of "load"

6. Unexpected behavior from $interp eval "exit"

7. BUG: "exec" behavior changed

8. "grid propagate .win 0" incorrect behavior

9. expect "debug on" behavior changed

10. Strange window size behavior using "-setgrid"

11. Strange "for" loop behavior

12. Strange "event genrate" behavior

 

 
Powered by phpBB® Forum Software