/// <summary>Constructor.</summary> /// <param name="model">The logical model of the button</param> /// <param name="container">The HTML container of the button.</param> protected ButtonView(IButton model, jQueryObject container) : base(InitContainer(container)) { // Setup initial conditions. if (Script.IsNullOrUndefined(model)) model = new ButtonBase(); this.model = model; Focus.BrowserHighlighting = false; // Setup CSS. Css.InsertLink(Css.Urls.CoreButtons); Container.AddClass(ClassButton); Container.AddClass(Css.Classes.NoSelect); // Insert the content and mask containers. divContent = CreateContainer("buttonContent"); // Create child controllers. eventController = new ButtonEventController(this); contentController = new ButtonContentController(this, divContent); // Wire up events. Model.LayoutInvalidated += OnLayoutInvalidated; Helper.ListenPropertyChanged(Model, OnModelPropertyChanged); eventController.PropertyChanged += OnEventControllerPropertyChanged; GotFocus += delegate { UpdateLayout(); }; LostFocus += delegate { UpdateLayout(); }; IsEnabledChanged += delegate { UpdateLayout(); }; Container.Keydown(delegate(jQueryEvent e) { OnKeyPress(Int32.Parse(e.Which)); }); // Finish up. SyncCanFocus(); }
/// <summary>Constructor.</summary> /// <param name="model">The logical model of the button</param> /// <param name="container">The HTML container of the button.</param> /// <param name="clickMask">The element used catch mouse events.</param> protected ButtonView(IButton model, jQueryObject container, jQueryObject clickMask) : base(InitContainer(container)) { // Setup initial conditions. if (Script.IsNullOrUndefined(model)) model = new ButtonModel(); this.model = model; this.clickMask = clickMask; // Setup CSS on container. Container.AddClass(ClassButton); Container.AddClass(Css.Classes.NoSelect); Focus.BrowserHighlighting = false; // Make the container position relative (if it doesn't have an explicit position set).)) if (string.IsNullOrEmpty(Container.GetCSS(Css.Position))) { Container.CSS(Css.Position, Css.Relative); } // Setup the event monitor. if (Script.IsNullOrUndefined(clickMask)) clickMask = Container; eventController = new ButtonEventController(this, clickMask); // Wire up events. Helper.ListenPropertyChanged(Model, OnModelPropertyChanged); eventController.PropertyChanged += OnEventControllerPropertyChanged; GotFocus += delegate { UpdateLayout(); }; LostFocus += delegate { UpdateLayout(); }; IsEnabledChanged += delegate { UpdateLayout(); }; Container.Keydown(delegate(jQueryEvent e) { OnKeyPress(Int32.Parse(e.Which)); }); // Finish up. SyncCanFocus(); }