Lisp HUG Maillist Archive

Filtering characters into CAPI text-input-pane

Thanks again for the list for the great help with the title in frame
information. The application is coming along well, but there is a
feature I'd like to implement and I wonder how to best accomplish
that.

I'd like to have a text-input-pane that will only accept
positive, floating-point numbers. That is, characters [0-9\.]
The :confirm-change-function looks perfect for the job of restricting
non-numeric characters, but is only implemented on Motif.

One potential work around I though of is that when the input is done,
and if there are invalid characters, to blank the field, beep, and
reset focus to the field. Another work-around is to use
text-input-range, but that only supports integers.

My first preference is to just prevent invalid characters from being
entered in this first place. Since :confirm-change-function isn't
available on all platforms, is there another possibility that I'm not
seeing, like applying a filter to stream of input characters?

Thanks in advance for any ideas,

Kevin


Re: Filtering characters into CAPI text-input-pane

On Thursday 10 January 2008 2:55:02 pm Kevin Rosenberg wrote:
> Thanks again for the list for the great help with the title in frame
> information. The application is coming along well, but there is a
> feature I'd like to implement and I wonder how to best accomplish
> that.

Try change-callback.

Look at the examples/elements/text-input-pane.lisp.  I think that the example 
does kind-of what you want (it prevents typing of more than 20 chars).

pt


Re: Filtering characters into CAPI text-input-pane

Kevin,

Why not use the change-callback for text-input-pane?

It's called every time the text or caret position is changed. You can  
filter and replace the text, along with the caret position. (See CAPI  
Reference Manual for text-input-pane.)

Laughing Water


On Jan 10, 2008, at 12:55 PM, Kevin Rosenberg wrote:

>
> Thanks again for the list for the great help with the title in frame
> information. The application is coming along well, but there is a
> feature I'd like to implement and I wonder how to best accomplish
> that.
>
> I'd like to have a text-input-pane that will only accept
> positive, floating-point numbers. That is, characters [0-9\.]
> The :confirm-change-function looks perfect for the job of restricting
> non-numeric characters, but is only implemented on Motif.
>
> One potential work around I though of is that when the input is done,
> and if there are invalid characters, to blank the field, beep, and
> reset focus to the field. Another work-around is to use
> text-input-range, but that only supports integers.
>
> My first preference is to just prevent invalid characters from being
> entered in this first place. Since :confirm-change-function isn't
> available on all platforms, is there another possibility that I'm not
> seeing, like applying a filter to stream of input characters?
>
> Thanks in advance for any ideas,
>
> Kevin
>
>


Updated at: 2020-12-10 08:44 UTC