PressableControl.MouseHovering

Jan 12, 2012 at 11:55 PM

I am having trouble using the MouseHovering property on my ButtonControls. I seems to be always false, wherever I put the mouse pointer. Is there some trick to using this property or is it just plain broken?

Jan 13, 2012 at 3:23 AM

It works for me - make sure you don't have something at a higher Z-Order

Jan 13, 2012 at 12:50 PM

I also realized that could be the problem, however, it doesn't seem to be.

 

if(headSlotButton.MouseHovering)
            {
                headSlotButton.Text = "hovering";
            }
From debugging I know that the if is reached in every tick when the dialog window is open, however, wherever I put the mouse pointer, the control never reaches the inner block. The MouseHovering property is simply false all the time.

Jan 14, 2012 at 3:08 AM

I think you have to be using the built in input library too - are you? (I'm not sure on this)

Jan 14, 2012 at 3:17 PM

I do have

input = new InputManager(Services, Window.Handle);
            Components.Add(this.input);
in the Innitialize method of the main class, wchich should put the NuclexInput in charge of things, if that's what you mean.

Jan 16, 2012 at 9:39 PM

I have found a solution (or workaround, rather), so I guess I might as well share it for anyone who might encounter similar difficulties.

Basically I just created my own class, that inherited ButtonControl and reimplemented the MouseHovering property, which works as expected.

 

 public class MyButtonControl : ButtonControl
    {
        new public bool MouseHovering
        {
            get 
            {
               RectangleF button = this.GetAbsoluteBounds();
               RectangleF mouse = new RectangleF(Mouse.GetState().X, Mouse.GetState().Y, 0, 0);
               return button.Contains(mouse);
            }
        }
}