To make a pane that is wide enough to accomodate a given string, use the
:visible-min-width
hint with a
(:string
string
)
constraint.
In this example we also supply
:visible-max-width t
, which fixes the maximum visible width to be the same as the minimum visible width. Hence the pane is wide enough, but no wider:
(defvar *text* "Exactly this wide")
(capi:contain
(make-instance 'capi:text-input-pane
:text *text*
:visible-min-width `(:string ,*text*)
:visible-max-width t
:font (gp:make-font-description
:size (+ 6 (random 30)))))
Note that the width constraint works regardless of the font used.