Lisp HUG Maillist Archive

How to transfer focus from tree-view

I would like to have the focus change to another pane when a tree-view 
node is selected.  Stepping through the code, I can see that this works, 
but when the selection-callback is exited, focus transfers back to the 
tree-view.

Can I make the focus change stay where the callback puts it?  Thanks for 
any help.

Mitch

This demonstrates:

(capi:define-interface focus-test-interface ()
   ()
   (:panes
    (test-pane-1
     capi:text-input-pane
     :accessor test-pane-1
     :title "Test Pane 1"
     :title-position :frame
     :visible-min-height 50)
    (test-pane-2
     capi:text-input-pane
     :accessor test-pane-2
     :title "Test Pane 2"
     :title-position :frame
     :visible-min-height 50)
    (pick-tree
     capi:tree-view
     :roots '(0)
     :children-function #'(lambda (x) (when (= x 0) (list 1 2)))
     :selection-callback 'pick-tree-callback
     :callback-type :interface-data
     :visible-min-height 100))
   (:layouts
    (main-layout
     capi:column-layout
     '(test-pane-1 test-pane-2 pick-tree)))
   (:default-initargs
    :layout 'main-layout
    :best-width 100
    :title "Focus test"))

(defun pick-tree-callback (interface data)
   (cond
    ((= data 1)
     (capi:apply-in-pane-process interface #'capi:set-pane-focus 
(test-pane-1 interface)))
    ((= data 2)
     (capi:apply-in-pane-process interface #'capi:set-pane-focus 
(test-pane-2 interface)))))

(capi:contain (make-instance 'focus-test-interface))


Re: How to transfer focus from tree-view

On Fri, Oct 10, 2008 at 09:36:01PM -0400, Mitch Berkson wrote:
> I would like to have the focus change to another pane when a
> tree-view node is selected.  Stepping through the code, I can see
> that this works, but when the selection-callback is exited, focus
> transfers back to the tree-view.
> 
> Can I make the focus change stay where the callback puts it?  Thanks
> for any help.

Running your sample code as is, in a listener, with no debugging or
tracing or stepping or whatever, works for me.  (Lispworks for Linux
Pro 5.1.)  I did not try it in the stepper.

I note that when I click in the tree-view, focus is briefly
transferred to the tree-view while I hold the mouse button down, then
transferred to the appropriate test pane when I release the mouse
button.

-- L


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