Lisp HUG Maillist Archive

Pane menu possible for text input panes?

Is there a way to implement pane menu for text input panes (or even
better, multi-line pane menus)? It seems to work for other panes, such
as title pane, but for input panes there seems to be some default pane
menu which overrides the pane menu.

It also seems like input pane also overrides input model callbacks
even when it is inside pinboard layout, so this does not help either.
Is my only option to implement my own input pane?

; right mouse click brings pane menu
(capi:contain (make-instance 'capi:title-pane :text "asdhasdhasd"
:pane-menu (make-instance 'capi:menu :items '(:foo :bar))))

; for input pane it brings default menu
(capi:contain (make-instance 'capi:text-input-pane :text "asdhasdhasd"
:pane-menu (make-instance 'capi:menu :items '(:foo :bar))))

; slightly more complicated
(defun popup-test-menu (pane x y &optional gspec)
  (declare (ignore gspec))
  (capi:display-popup-menu
   (make-instance 'capi:menu :items '(:hih :hei))
   :owner pane :x x :y y))

(capi:contain
 (make-instance 'capi:pinboard-layout
                :description (list (make-instance 'capi:text-input-pane
                                                  :pane-menu #'(lambda (a b x y)

(make-instance 'capi:menu :items '(:foo :bar) :x x :y y))
                                                  :text "foobar"
                                                  :x 0
                                                  :y 0)
                                   (make-instance 'capi:title-pane
                                                  :text "asdhasjd"
                                                  :x 0
                                                  :y 30
                                                  :pane-menu #'(lambda (a b x y)

(make-instance 'capi:menu :items '(:zip :zap) :x x :y y))))
                :input-model
                '((:post-menu popup-test-menu))
                :visible-min-width 100
                :visible-min-height 100))

Best regards,

Mikko


Re: Pane menu possible for text input panes?

Sorry, the code somehow got garbled. Here is the correct code:

(defun popup-test-menu (pane x y &optional gspec)
 (declare (ignore gspec))
 (capi:display-popup-menu
  (make-instance 'capi:menu :items '(:hih :hei))
  :owner pane :x x :y y))

(capi:contain
 (let ((a (make-instance 'capi:title-pane
                         :pane-menu #'(lambda (a b x y)
                                        (make-instance 'capi:menu
:items '(:foo :bar) :x x :y y))
                         :text "foobar"
                         :x 0
                         :y 0))
       (b (make-instance 'capi:text-input-pane
                         :pane-menu #'(lambda (a b x y)
                                        (make-instance 'capi:menu
:items '(:foo :bar) :x x :y y))
                         :text "foobar"
                         :x 0
                         :y 50)))
   (make-instance 'capi:pinboard-layout
                  :description (list a b)
                  :input-model
                  '((:post-menu popup-test-menu))
                  :visible-min-width 100
                  :visible-min-height 100)))

Best regards,

Mikko

On Tue, Apr 7, 2009 at 11:12 PM, Mikko Ahonen <mikko.ahonen@iki.fi> wrote:
> Is there a way to implement pane menu for text input panes (or even
> better, multi-line pane menus)? It seems to work for other panes, such
> as title pane, but for input panes there seems to be some default pane
> menu which overrides the pane menu.
>
> It also seems like input pane also overrides input model callbacks
> even when it is inside pinboard layout, so this does not help either.
> Is my only option to implement my own input pane?
>
> ; right mouse click brings pane menu
> (capi:contain (make-instance 'capi:title-pane :text "asdhasdhasd"
> :pane-menu (make-instance 'capi:menu :items '(:foo :bar))))
>
> ; for input pane it brings default menu
> (capi:contain (make-instance 'capi:text-input-pane :text "asdhasdhasd"
> :pane-menu (make-instance 'capi:menu :items '(:foo :bar))))
>
> ; slightly more complicated
> (defun popup-test-menu (pane x y &optional gspec)
>  (declare (ignore gspec))
>  (capi:display-popup-menu
>   (make-instance 'capi:menu :items '(:hih :hei))
>   :owner pane :x x :y y))
>
> (capi:contain
>  (make-instance 'capi:pinboard-layout
>                :description (list (make-instance 'capi:text-input-pane
>                                                  :pane-menu #'(lambda (a b x y)
>
> (make-instance 'capi:menu :items '(:foo :bar) :x x :y y))
>                                                  :text "foobar"
>                                                  :x 0
>                                                  :y 0)
>                                   (make-instance 'capi:title-pane
>                                                  :text "asdhasjd"
>                                                  :x 0
>                                                  :y 30
>                                                  :pane-menu #'(lambda (a b x y)
>
> (make-instance 'capi:menu :items '(:zip :zap) :x x :y y))))
>                :input-model
>                '((:post-menu popup-test-menu))
>                :visible-min-width 100
>                :visible-min-height 100))
>
> Best regards,
>
> Mikko
>


Re: Pane menu possible for text input panes?

Here are my findings in case somebody is wondering the same thing in the future.

Paul's idea is how it should be done. Unfortunately it works on
Windows but not on OS X.

According to LW tech support, this feature would degrade performance
for the panes that do not have custom pane menus, and thus it will not
be supported.

Example, based on Paul's idea, Windows-only:

(capi:define-interface test ()
 ()
 (:panes
  (e1 capi:rich-text-pane))
 (:layouts
  (main-layout capi:column-layout '(e1)))
 (:menu-bar  )
 (:default-initargs
  :visible-min-width 200
  :visible-min-height 300))

(defun my-callback (pane)
 (capi:display-message "Callback on pane ~S." pane))

(defmethod capi:pane-popup-menu-items ((self capi:rich-text-pane)
(interface test))
 (list*
  (make-instance 'capi:menu-item
                 :title "Item for My Editor Menu."
                 :selection-callback 'my-callback)
  (call-next-method)))

Regards,

Mikko

On Wed, Apr 8, 2009 at 12:03 AM, Paul Tarvydas
<tarvydas@visualframeworksinc.com> wrote:
> I had this figured out (for rich-text-panes) a couple of weeks ago :-), but
> I'm rushing out and can't remind myself of the details until later.
>
> Look at the ref pages for:
>
> make-pane-popup-menu
>
> make-menu-for-pane
>
> pane-popup-menu-items
>
> and there's an example somewhere. As far as I remember, capi calls one of
> these when the :post-menu input model item is invoked - you need to
> specialize one of these methods (guess: pane-popup-menu-items) and
> call-next-method appropriately. Feel free to email me later tonight /
> tomorrow if you can't figure it out. The example also demonstrates how to
> temporarily append the menu to the main interface menu for added swoopiness.
>
> pt


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