Ian Vink
Ian Vink

Reputation: 68750

MonoTouch.Dialog: GlassButton in Section

I have a standard DialogViewControler which adds a Section with a View as the constructor:

Section sec = new Section (new LogoHeaderView (320, 87));

In the LogoHeaderView I add a MT.Dialog GlassButton

        btnContact = new GlassButton (frameContact);    
        btnContact.SetTitle ("Contact", UIControlState.Normal);
        btnContact.NormalColor = Settings.ButtonNormalColor;
        btnContact.HighlightedColor = Settings.ButtonHighlightColor;
        btnContact.Tapped += (obj) => {};
        btnContact.Enabled=true;
        AddSubview (btnContact);

The view renders nicely, however the button is not clickable and the Tapped event never activates. It's like it's not enabled?

How do I get a GlassButton to appear in a View in a Section and work like a button? enter image description here

Upvotes: 3

Views: 855

Answers (1)

poupou
poupou

Reputation: 43553

It works for me. However if your GlassButton is outside your UIView limits it won't receive the tap events (it's a UIView thing not a GlassButton issue).

E.g. This does not work

        UIView view = new UIView (new RectangleF (0, 0, 200, 10));
        view.MultipleTouchEnabled = true;
        GlassButton gb = new GlassButton (new RectangleF (10,10,100,100));
        gb.SetTitle ("Contact", UIControlState.Normal);
        gb.Enabled = true;
        gb.Tapped += delegate {
             Console.WriteLine ("hello");
        };
        view.AddSubview (gb);

but change the first line to:

        UIView view = new UIView (new RectangleF (0, 0, 200, 200));

and you'll be able to click the button.

Upvotes: 3

Related Questions