Mouseover color effect is lost on color change

11 posts, 0 answers
  1. Andre
    Andre avatar
    30 posts
    Member since:
    Dec 2012

    Posted 25 Jan 2013 Link to this post

    When i change the color of the tile the default mouse-over color change effect disappears. How do i re enable this.
  2. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 30 Jan 2013 Link to this post

    Hello Andre,

    Thank you for writing.

    Setting the BackColor of the TileElement in code has higher precedence than the theme and this is why the hover color is not applied. You have two options:
    1. Modify the default theme and change the tile BackColor in it - see attached image demonstrating which repository you should modify. Here are some additional links that you might find useful:

    2. Subscribe to the MouseEnter event of your tiles and when it occurs change the tile BackColor. Also, you will need to reset this setting when the MouseLeave event occurs:
    void Form1_MouseLeave(object sender, EventArgs e)
    {
        RadTileElement el = (RadTileElement)sender;
        el.BackColor = Color.Red;
    }
     
    void Form1_MouseEnter(object sender, EventArgs e)
    {
        RadTileElement el = (RadTileElement)sender;
        el.BackColor = Color.Yellow;
    }

    I hope this helps.

    Regards,
    Stefan
    the Telerik team
    Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 30 Jan 2013 Link to this post

    I forgot the attachment. Here is it.
     
    Kind regards,
    Stefan
    the Telerik team
    Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
  5. Andre
    Andre avatar
    30 posts
    Member since:
    Dec 2012

    Posted 30 Jan 2013 Link to this post

    Thanks. This is helpful. I'm trying to decide which way to go. I'd like to have tiles of various colors. Just so i understand correctly, if i went with your first suggestion, would i have to create several themes? ( One for each color? )

    If so, maybe it'd be easier, if i did the color change in code like you suggest in option 2. 

    Thanks again for your help.
  6. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 30 Jan 2013 Link to this post

    Hello Andre,

    If you want to have different colors for the different tiles, you should go with option 2 since in the theme you can set just the default color for all tiles used in RadPanorama.
     
    Greetings,
    Stefan
    the Telerik team
    Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
  7. Andre
    Andre avatar
    30 posts
    Member since:
    Dec 2012

    Posted 30 Jan 2013 Link to this post

    I don't see (attached) the mouse events for the tiles.
  8. Andre
    Andre avatar
    30 posts
    Member since:
    Dec 2012

    Posted 30 Jan 2013 Link to this post

    Sorry, I looked into this a little further, I'll hook up the handlers in code i.e.

    radTileElement1.MouseHover += new EventHandler(radTileElement1_MouseHover);

    Thanks for all your help. Very responsive.
  9. Andre
    Andre avatar
    30 posts
    Member since:
    Dec 2012

    Posted 20 Feb 2013 Link to this post

    There seems to be a problems with this solution when using groups. The mouseEnter event is triggered, but the mouseLeave event is not. 

    Is this a know bug?
  10. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 25 Feb 2013 Link to this post

    Hello Andre,

    Thank you for writing back.

    It seems that there is an issue with the MouseLeave event in this case. I will log it in our
    Public Issue Tracking System and we will address it accordingly. Here is the link to it: http://www.telerik.com/support/pits.aspx#/public/winforms/14359.

    Your Telerik Points have been updated for this report.

    As a workaround, you can use the control's MouseMove event in the following manner:
    RadTileElement saveTile;
          void radPanorama1_MouseMove(object sender, MouseEventArgs e)
          {
              RadTileElement tile = radPanorama1.ElementTree.GetElementAtPoint(e.Location) as RadTileElement;
              if (tile != null)
              {
                  if (saveTile != null)
                  {
                      saveTile.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local);
                  }
     
                  tile.BackColor = Color.Yellow;
                  saveTile = tile;
              }
              else if (saveTile != null)
              {
                  saveTile.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local);
              }
          }

    I hope this helps.

    Greetings,
    Stefan
    the Telerik team
    Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
  11. Derek
    Derek avatar
    6 posts
    Member since:
    Jun 2013

    Posted 17 Jun 2013 Link to this post

    Stefan,

    Thank you for the code. This is a nice work around for tiles that are in groups. However, this example voids the set backcolor for the tile once the mouse leaves the tile. So, the mouse will enter the tile for a nice scroll over effect, but then it resets the backcolor to the default blue for the control. Is there a way to go back to a set backcolor?

    Thanks,

    Derek
  12. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 20 Jun 2013 Link to this post

    Hello,

    No, there is no way to revert back to another locally set BackColor. What I can offer is to store the desired color for a tile in its Tag property and instead of using the reset, get the color from the Tag and set it instead.

    I hope this will work for you.
     
    Regards,
    Stefan
    Telerik
    RadChart for WinForms is obsolete. Now what?
Back to Top
UI for WinForms is Visual Studio 2017 Ready