Lisp HUG Maillist Archive

Tab-control problems: Panes on 2., 3. etc tabs not created initially - how am I notified?

Hello,

LWW Pro 4.4.6

I have an interface that contains a tab-layout with three tabs. Each tab has a layout with some panes in. When the interface is created, the panes on the first tab are also created. The panes on the other tabs are not created until I switch to them (by clicking with the mouse).

However, I want to fill a multi-line-text-input pane on the third tab with some text programmatically, so it's there if the user ever looks at it. It fails, since the pane doesn't exist. I tought I could get notified when the pane was created, via a callback. The callback could fill the pane with the text. But my callback is never called.

So, 1) what is the way I should have done this, and 2) why doesn't my callback get called?


I have included below the complete definition of the interface (built by the interface-builder). The callback functions are not shown. In desperation, I tried adding a title-pane and a push-button-pane to the third layout (the runtime-status-layout). But their :focus callbacks are not called either. The only callback I'm able to have called, is the callback when the user presses the button (push-button-1), but then it's too late, and that's not what I want.

Thank you.


Eivind


BTW, I'll be away the coming week, probably without e-mail, so if anyone asks me a follow-up question my answer will be late.



(in-package "COMMON-LISP-USER")


(capi:define-interface scenario-status-window ()
  ()
  (:panes
   (title-pane-1
    capi:title-pane
    :text "Scenario file:"
    :internal-border 2
    :visible-border t)
   (scenario-file-name
    capi:title-pane
    :text "..."
    :internal-border 2
    :visible-border t)
   (scenario-load-status
    capi:rich-text-pane
    :enabled t
    :internal-border 20
    :visible-border t)
   (general-note-pane-1
    capi:title-pane
    :text "(...)."
    :internal-border 2
    :visible-border t)
   (previous-commands
    capi:text-input-choice
    :items nil
    :multi-line-p t
    :visible-items-count 20
    :selection-callback #'callback-select-previous-command)
   (button-test-command
    capi:push-button
    :text "Test command"
    :callback #'button-test-command)
   (button-send-command
    capi:push-button
    :text "Send command"
    :callback #'button-send-command)
   (button-copy-command
    capi:push-button
    :text "Copy command"
    :callback #'button-copy-command)
   (input-command-text-wnd
    capi:multi-line-text-input-pane)
   (input-command-result-wnd
    capi:multi-line-text-input-pane)
   (title-pane-2
    capi:title-pane
    :text "Runtime messages")
   (runtime-messages
    capi:multi-line-text-input-pane
    :accepts-focus-p t)
   (push-button-1
    capi:push-button
    :text "Clear window"
    :accepts-focus-p t
    :callback #'runtime-message-focus
    :callback-type :focus))
  (:layouts
   (tab-layout-1
    capi:tab-layout
    ()
    :items '(("Scenario load status" loadtime-status-layout) ("Test commands" command-test-layout) ("Runtime messages" runtime-status-layout))
    :enabled t
    :print-function 'car
    :visible-child-function 'second
    :initial-focus-item 'runtime-status-layout)
   (loadtime-status-layout
    capi:column-layout
    '(row-layout-2 scenario-load-status row-layout-5)
    :enabled t)
   (row-layout-2
    capi:row-layout
    '(title-pane-1 scenario-file-name)
    :border 4)
   (row-layout-5
    capi:row-layout
    '(general-note-pane-1))
   (command-test-layout
    capi:column-layout
    '(row-layout-4 input-command-text-wnd input-command-result-wnd)
    :enabled t
    :y-ratios '(1 2 30))
   (row-layout-4
    capi:row-layout
    '(previous-commands button-test-command button-send-command button-copy-command))
   (runtime-status-layout
    capi:column-layout
    '(title-pane-2 runtime-messages push-button-1)
    :border 4
    :enabled t
    :initial-focus 'push-button-1))
  (:default-initargs
   :best-height 300
   :best-width 453
   :layout 'tab-layout-1
   :title "Scenario status"))









Re: Tab-control problems: Panes on 2., 3. etc tabs not created initially - how am I notified?

Hello Eivind,

| Hello,
|
| LWW Pro 4.4.6
|
| I have an interface that contains a tab-layout with three tabs. Each
| tab has a layout with some panes in. When the interface is created, the
| panes on the first tab are also created. The panes on the other tabs
| are not created until I switch to them (by clicking with the mouse).
|
| However, I want to fill a multi-line-text-input pane on the third tab
| with some text programmatically, so it's there if the user ever looks
| at it. It fails, since the pane doesn't exist. I tought I could get
| notified when the pane was created, via a callback. The callback could
| fill the pane with the text. But my callback is never called.
|
| So, 1) what is the way I should have done this, and 2) why doesn't my
| callback get called?
|...snip...|

For such purpose, I fill in the tab-layout with items that are instances of
the tab-page-mixin and provide the following hack to invoke the
create-callback of my own (tested only on LWW):

(defclass tab-page-mixin ()
 (;; Signature: (interface tab-page-mixin)
  (create-callback :reader create-callback :initarg :create-callback
:initform nil)
))

(defmethod CAPI::MAYBE-INSTALL-DESCRIPTION :around
         ((tab-page-mixin tab-page-mixin))
  (let ((result (call-next-method)))
    (unless result
      (when-let (create-callback (create-callback tab-page-mixin))
        ;; Simply clobber the callback as it is of no value any longer.
        (setf (slot-value tab-page-mixin 'create-callback) nil)
        (funcall create-callback (capi:element-interface tab-page-mixin)
tab-page-mixin)))
    result))
--
Sincerely,
Dmitriy Ivanov
lisp.ystok.ru


Re: Tab-control problems: Panes on 2., 3. etc tabs not created initially - how am I notified?

Unable to parse email body. Email id is 5379

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