Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!bb3.andrew.cmu.edu!newsfeed.pitt.edu!gatech!news.mathworks.com!uunet!in2.uu.net!news.sprintlink.net!news.emi.net!news
From: news@emi.net (EmiNet Domain News Admin)
Subject: Re: [VW2] Limiting text entry in TextEditorView
Content-Type: Text/Plain; charset=ISO-8859-1
X-Newsreader: WinVN 0.99.5
Organization: Your Organization
Message-ID: <DpoICC.Kts@emi.net>
References: <4kf8ks$l3p@viking.mpr.ca>
Mime-Version: 1.0
X-Nntp-Posting-Host: ttydc.emi.net
Date: Thu, 11 Apr 1996 03:43:24 GMT
Lines: 39

In article <4kf8ks$l3p@viking.mpr.ca>, amacarth@newshost says...
>
>I need someting like maxChars in InputBoxController for the
>TextEditorController.  This limits the number of characters being
>displayed on the widget, and will not display any more than the
>maxChars allows.  Presently, I am doing validation on exit from the
>TextEditorView to ensure the string is not too long, but this seems to
>be pretty poor behaviour in terms of usability.
>
>Does anyone know an easy way to do this, hopefully other than
>implementing a new Controller class?
>
>Thanks in advance.
>
>--
>Angus MacArthur
>
>"A mathematician is a device for turning coffee into theorems."
>        -- P. Erdos
>


You could probably use the keyboardHook facility on some of the controller 
classes (including the superclass of your controller). The keyboardHook is 
actually a block which takes two arguments (look at the way it's used in the 
system....senders/implementorsOf etc).

If the block returns nil no further processing takes place so in the block you 
could carry out some checks on the number of characters and take appropriate 
action otherwise.

So just grab the controller in, for example, the a postBuild: method and fix 
the block into place.

I haven't actually had to implement this in the past so it's only a suggestion. 
If it's wrong I'm sure someone in this group will correct me.

Joe TekNomad

