NSTokenField inside nsscrollview

158 views Asked by At

becauseNStokenField doesn't support scroll bars, I embed it inside scroll view, but it doesn't work ... At first I used constraints fot NSTokenField like this :

enter image description here

but it seems that NTToken frame height isn't changed while typing much tags , than I tried to increase it dynamically, here is what I did :

public override void ViewWillAppear ()
        {
            base.ViewWillAppear ();
            this.View.Window.MakeKeyAndOrderFront (this);
            TxtTagField.Changed += (o, e) => {
                ResizeTokenField ();
            };
        }

        void ResizeTokenField ()
        {
            //

            if (!TxtTagField.Cell.Wraps) {
                return;
            }

            CGRect frame = TxtTagField.Frame;
            var width = frame.Size.Width;
            var size = frame.Size;
            size.Height = nfloat.MaxValue;
            frame.Size = size;
            nfloat height = TxtTagField.Cell.CellSizeForBounds (frame).Height;
            if (height > 44) {
                var fr = TxtTagField.Frame;
                fr.Size = new CGSize (width, height + 23);
                InvokeOnMainThread (() => {
                    TxtTagField.Frame = fr;
                });
            }
}

but still get no result :(

0

There are 0 answers