Lisp HUG Maillist Archive

catching Return in multi-line-text-input-pane

Hello all,

I'm trying to mimic the behavior of some instant messaging clients
I've used. I'd like an area for text input which would allow text to
be entered, automatically wrapping if the line is too long, and upon
pressing Enter/Return, some callback is invoked. The ability to insert
a real newline would be nice, but I can live without it too.

I'm working with LWM 5.0.2.

capi:text-input-pane accepts a callback which is invoked upon pressing
Enter, and by specifying heights I can get the actual pane to be
taller, and by pressing C-Q return I can manually insert newline
characters. Unfortunately, text doesn't seem to wrap.

capi:multi-line-text-input pane handles wrapping by default, but both
return and C-Q return insert newlines (as I'd expect from the docs).

Is there an easy way to get something that looks and acts like a
multi-line-text-input-pane with the exception that return triggers
callback?

(If there's not, then I'll go and see what I can do with
change-callback, but I'm hoping there's an easier way.)

Thanks in advance!

-- 
=====================
Joshua Taylor
tayloj@rpi.edu

"A lot of good things went down one time,
     back in the goodle days."
               John Hartford


Re: catching Return in multi-line-text-input-pane


On May 29, 2007, at 5:37 PM, Taylor, Joshua wrote:

> capi:multi-line-text-input pane handles wrapping by default, but both
> return and C-Q return insert newlines (as I'd expect from the docs).
>
> Is there an easy way to get something that looks and acts like a
> multi-line-text-input-pane with the exception that return triggers
> callback?
>
> (If there's not, then I'll go and see what I can do with
> change-callback, but I'm hoping there's an easier way.)


This is not exactly what you are looking for, but it might give you  
some ideas. I needed the text-input-pane to allow returns (pasted in  
or with option-return) but still execute the default action if the  
return key was pressed.

; issue: multi-line-text-input-pane does not call the callback when  
return is pressed -- we want that in dialogs
; to execute the default button. But we still want returns to be  
enterable with option-return. So this class
; creates an :around method for setting the text which appears to be  
the place where the normal text-input-pane
; generates an error if you try to include a return

(defclass text-input-pane-allows-returns (text-input-pane)
   ())

(defmethod (setf text-input-pane-text) :around (new-text (pane text- 
input-pane-allows-returns))
   (setf (capi::text-input-pane-multi-line-p pane) t)
   (prog1 (call-next-method)
     (setf (capi::text-input-pane-multi-line-p pane) nil)))




John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL


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