Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8431849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:58:02+00:00 2026-06-10T05:58:02+00:00

I am trying to add a class to an instance of a subclass of

  • 0

I am trying to add a class to an instance of a subclass of goog.ui.Button when the user hovers over the button.

To this end, I overrode handleMouseOver:

/**
 * Handles mouseover events.
 * @param {goog.events.BrowserEvent} e Mouse event to handle.
 * @override
 */
myapp.ui.Button.prototype.handleMouseOver = function(e) {
  goog.base(this, 'handleMouseOver', e);
  goog.dom.classes.add(this.getElement(), 'button-hover-state');
};

However, when I hover over the button, the class ‘button-hover-state’ is not added to the button. Why not? Chrome Console is not issuing any errors or warnings.

I could listen to an event and respond instead of overriding handleMouseOver, but shouldn’t overriding this function alter what happens when the mouse enters the element?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T05:58:04+00:00Added an answer on June 10, 2026 at 5:58 am

    The reason why your method myapp.ui.Button.prototype.handleMouseOver does not do anything is because mouse events are not being dispatched.

    The default renderer used by goog.ui.Button is goog.ui.NativeButtonRenderer. The method goog.ui.NativeButtonRenderer.prototype.createDom calls goog.ui.NativeButtonRenderer.prototype.setUpNativeButton_, which in turn, calls:

    button.setHandleMouseEvents(false);
    

    There are couple of approaches you could use to enable mouse events.

    Use the default button renderer and override goog.ui.Component.prototype.render

    /**
     * Renders the button.
     *
     * @param {Element=} opt_parentElement Optional parent element to render the
     *    component into.
     * @override
     */
    myapp.ui.Button.prototype.render = function(opt_parentElement) {
      goog.base(this, 'render', opt_parentElement);
      this.setHandleMouseEvents(true);
    }; 
    

    Use a different default renderer such as goog.ui.ButtonRenderer

    /**
     * My custom button.
     *
     * @param {goog.ui.ControlContent} content Text caption or existing DOM
     *     structure to display as the button's caption.
     * @param {goog.ui.ButtonRenderer=} opt_renderer Renderer used to render or
     *     decorate the button; defaults to {@link goog.ui.NativeButtonRenderer}.
     * @param {goog.dom.DomHelper=} opt_domHelper Optional DOM hepler, used for
     *     document interaction.
     * @constructor
     */
    myapp.ui.Button = function(content, opt_renderer, opt_domHelper) {
      goog.base(this, content,
          opt_renderer || goog.ui.ButtonRenderer.getInstance(), opt_domHelper);
    };
    goog.inherits(myapp.ui.Button, goog.ui.Button);
    

    When using goog.ui.ButtonRenderer, the CSS class goog-button-hover is automatically added to the button when the mouse hovers over the button and removed when the mouse leaves the button.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to add a class (.active) to a text field once the user
Is something wrong with the construction of this class? I am trying to add
i am trying to add class on on-click jquery event for that i am
I'm trying to add class visible to a div with the same ID as
Trying to add a class object into a List using reflection, but when invoking
Im trying to add a class to a each element in a collection. I
I'm trying to add a class to some input elements depending on the type,
I am trying to add a class of 'nocheck' to a specific image with
Im new to asp.net mvc. I'm trying add new model class but it got
Trying to add a dynamic class value to one of my columns in CGridView:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.