Initial focus in a dialog box
I have a dialog defined as follows:
------
(capi:define-interface dialog-1 ()
()
(:panes
(pane-1
capi:radio-button-panel
:layout-class 'capi:column-layout
:title "Buttons"
:items '("Item 1"
"Item 2"))
(buttons
capi:push-button-panel
:accessor dialog-1-buttons
:items '("OK" "Cancel")
:layout-args '(:x-uniform-size-p t)
:callback-type :interface
:callbacks '(capi:exit-dialog capi:abort-dialog)))
(:layouts
(main-layout
capi:column-layout
'(pane-1 buttons)
:x-adjust :centre))
(:default-initargs
:layout 'main-layout))
(capi:display-dialog (make-instance 'dialog-1))
------
That works fine, but now I want the "OK" button to have the initial
focus.
If add the following to the default initargs ...
:create-callback
#'(lambda (interface)
(capi:set-pane-focus
(first
(capi:layout-description
(capi:pane-layout
(dialog-1-buttons interface))))))
.... then things are as I want.
But is there a simpler way?
I tried defining the "OK" and "Cancel" buttons separately and
using :INITIAL-FOCUS in the interface's default initargs. That
works, but the "OK" button is smaller than the "Cancel" button
and I couldn't find a way to get the buttons to be the same
size.
Simon