LinkButton Formatting

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

LinkButton Formatting

Nick Makes
Hi all,

I'm running into issues with styles and event handling on LinkButtons that I was hoping someone could help me out with.

I'd like to control the hover and active/selected colors for these hyperlinks. I've managed the hover behavior by utilizing the mouseOver and mouseOut methods of the ComponentMouseListener. However, I think my mouseOut behavior (reverts the link's color back to the original state) overrides any color/style I'm setting in the mouseClick due to the fact you click only when the mouse is over the link, but then leave the hover area after clicking.

Is there a better/more accepted way of doing this? Perhaps a style key itself called hoverColor or something like that?

Any info or advice here would be greatly appreciated.

Thanks,
Nick

Sent from my iPhone
Reply | Threaded
Open this post in threaded view
|

RE: LinkButton Formatting

Roger Whitcomb-2
Hi Nick,
        A few suggestions:
1. Since the Pivot LinkButton only supports the "color" and "disabledColor" styles right now (you can see that in TerraLinkButtonSkin.java), you could totally manage the colors yourself in your mouse handling.  Sounds like you almost have this nailed.  Maybe you need to keep a little more state related to clicks?
2. You could create a custom LinkButtonDataRenderer, which does the painting, etc. the way you want it, then set that custom data renderer as the one used for all your LinkButtons.  This is (I think) the preferred way to do things.  This is the guy that actually does the underline painting, etc.  And this is totally customizable by creating a new renderer or just subclassing the default one.
3. You could create a custom component based on LinkButton, and make your own skin for it, based on the existing code, and add active/hover/whatever color styles and manage things that way.  You would probably end up also making a custom renderer as well.  If you look at the existing code, there's really not that much involved, but it is more work than option 2.
4. You could add these things to the Pivot code yourself, build from your custom build area, and submit a JIRA with a patch, and hope that we submit the code for the next release ;)  (sounds like a fine enhancement to me).

Would love to chat more about what you're doing :)

HTH,
~Roger

-----Original Message-----
From: Nick Makes [mailto:[hidden email]]
Sent: Thursday, July 03, 2014 9:28 AM
To: [hidden email]
Subject: LinkButton Formatting

Hi all,

I'm running into issues with styles and event handling on LinkButtons that I was hoping someone could help me out with.

I'd like to control the hover and active/selected colors for these hyperlinks. I've managed the hover behavior by utilizing the mouseOver and mouseOut methods of the ComponentMouseListener. However, I think my mouseOut behavior (reverts the link's color back to the original state) overrides any color/style I'm setting in the mouseClick due to the fact you click only when the mouse is over the link, but then leave the hover area after clicking.

Is there a better/more accepted way of doing this? Perhaps a style key itself called hoverColor or something like that?

Any info or advice here would be greatly appreciated.

Thanks,
Nick

Sent from my iPhone